public static int parseInt(String s, int offset, int length, int base)
        throws NumberFormatException {
        int value = 0;

        if (length < 0) {
            length = s.length() - offset;
        }

        for (int i = 0; i < length; i++) {
            char c = s.charAt(offset + i);

            int digit = convertHexDigit((int) c);
            if (digit < 0 || digit >= base) {
                throw new NumberFormatException(s.substring(offset, offset + length));
            }
            value = value * base + digit;
        }
        return value;
    }
Parse an int from a substring.
Negative numbers are not handled.

@param s      String
@param offset Offset within string
@param length Length of integer or -1 for remainder of string
@param base   base of the integer
@return the parsed integer
@throws NumberFormatException if the string cannot be parsed
src/main/java/spark/utils/urldecoding/TypeUtil.java