code: public void setFormat(int formatElementIndex, Format newFormat) {
          int formatNumber = 0;
          for (int partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
              if (formatNumber == formatElementIndex) {
                  setCustomArgStartFormat(partIndex, newFormat);
                  return;
              }
              ++formatNumber;
          }
          throw new ArrayIndexOutOfBoundsException(formatElementIndex);
      }
docs: Sets the Format object to use for the format element with the given
  format element index within the previously set pattern string.
  The format element index is the zero-based number of the format
  element counting from the start of the pattern string.
  <p>
  Since the order of format elements in a pattern string often
  changes during localization, it is generally better to use the
  {@link #setFormatByArgumentIndex setFormatByArgumentIndex}
  method, which accesses format elements based on the argument
  index they specify.
  
  @param formatElementIndex the index of a format element within the pattern
  @param newFormat the format to use for the specified format element
  @exception ArrayIndexOutOfBoundsException if formatElementIndex is equal to or
  larger than the number of format elements in the pattern string