code: private int parseOffsetFieldWithLocalizedDigits(String text, int start, int minDigits, int maxDigits,
              int minVal, int maxVal, int[] parsedLen) {
  
          parsedLen[0] = 0;
  
          int decVal = 0;
          int numDigits = 0;
          int idx = start;
          int[] digitLen = {0};
          while (idx < text.length() && numDigits < maxDigits) {
              int digit = parseSingleLocalizedDigit(text, idx, digitLen);
              if (digit < 0) {
                  break;
              }
              int tmpVal = decVal * 10 + digit;
              if (tmpVal > maxVal) {
                  break;
              }
              decVal = tmpVal;
              numDigits++;
              idx += digitLen[0];
          }
  
          // Note: maxVal is checked in the while loop
          if (numDigits < minDigits || decVal < minVal) {
              decVal = -1;
              numDigits = 0;
          } else {
              parsedLen[0] = idx - start;
          }
  
  
          return decVal;
      }
docs: Reads an offset field value. This method will stop parsing when
  1) number of digits reaches <code>maxDigits</code>
  2) just before already parsed number exceeds <code>maxVal</code>
  
  @param text the text
  @param start the start offset
  @param minDigits the minimum number of required digits
  @param maxDigits the maximum number of digits
  @param minVal the minimum value
  @param maxVal the maximum value
  @param parsedLen the actual parsed length is set to parsedLen[0], must not be null.
  @return the integer value parsed