bson/src/main/org/bson/internal/UnsignedLongs.java
public static long parse(final String string) {
        if (string.length() == 0) {
            throw new NumberFormatException("empty string");
        }
        int radix = 10;
        int maxSafePos = MAX_SAFE_DIGITS[radix] - 1;
        long value = 0;
        for (int pos = 0; pos < string.length(); pos++) {
            int digit = Character.digit(string.charAt(pos), radix);
            if (digit == -1) {
                throw new NumberFormatException(string);
            }
            if (pos > maxSafePos && overflowInParse(value, digit, radix)) {
                throw new NumberFormatException("Too large for unsigned long: " + string);
            }
            value = (value * radix) + digit;
        }

        return value;
    }
public static long parse(final String string) {
        if (string.length() == 0) {
            throw new NumberFormatException("empty string");
        }
        int radix = 10;
        int maxSafePos = MAX_SAFE_DIGITS[radix] - 1;
        long value = 0;
        for (int pos = 0; pos < string.length(); pos++) {
            int digit = Character.digit(string.charAt(pos), radix);
            if (digit == -1) {
                throw new NumberFormatException(string);
            }
            if (pos > maxSafePos && overflowInParse(value, digit, radix)) {
                throw new NumberFormatException("Too large for unsigned long: " + string);
            }
            value = (value * radix) + digit;
        }

        return value;
    }
public static long parse ( final String string ) { if ( string . length ( ) == 0 ) { throw new NumberFormatException ( "empty string" ) ; } int radix = 10 ; int maxSafePos = MAX_SAFE_DIGITS [ radix ] - 1 ; long value = 0 ; for ( int pos = 0 ; pos < string . length ( ) ; pos ++ ) { int digit = Character . digit ( string . charAt ( pos ) , radix ) ; if ( digit == - 1 ) { throw new NumberFormatException ( string ) ; } if ( pos > maxSafePos && overflowInParse ( value , digit , radix ) ) { throw new NumberFormatException ( "Too large for unsigned long: " + string ) ; } value = ( value * radix ) + digit ; } return value ; }
Equivalent to Long.parseUnsignedLong in Java 8.

@param string the string representation of an unsigned long
@return the unsigned long
Equivalent to Long . parseUnsignedLong in Java 8 .