code: private int readArgumentIndex(final String pattern, final ParsePosition pos) {
          final int start = pos.getIndex();
          seekNonWs(pattern, pos);
          final StringBuilder result = new StringBuilder();
          boolean error = false;
          for (; !error && pos.getIndex() < pattern.length(); next(pos)) {
              char c = pattern.charAt(pos.getIndex());
              if (Character.isWhitespace(c)) {
                  seekNonWs(pattern, pos);
                  c = pattern.charAt(pos.getIndex());
                  if (c != START_FMT && c != END_FE) {
                      error = true;
                      continue;
                  }
              }
              if ((c == START_FMT || c == END_FE) && result.length() > 0) {
                  try {
                      return Integer.parseInt(result.toString());
                  } catch (final NumberFormatException e) { // NOPMD
                      // we've already ensured only digits, so unless something
                      // outlandishly large was specified we should be okay.
                  }
              }
              error = !Character.isDigit(c);
              result.append(c);
          }
          if (error) {
              throw new IllegalArgumentException(
                      "Invalid format argument index at position " + start + ": "
                              + pattern.substring(start, pos.getIndex()));
          }
          throw new IllegalArgumentException(
                  "Unterminated format element at position " + start);
      }
docs: Read the argument index from the current format element
  
  @param pattern pattern to parse
  @param pos current parse position
  @return argument index