code: private String insertFormats(final String pattern, final ArrayList<String> customPatterns) {
          if (!containsElements(customPatterns)) {
              return pattern;
          }
          final StringBuilder sb = new StringBuilder(pattern.length() * 2);
          final ParsePosition pos = new ParsePosition(0);
          int fe = -1;
          int depth = 0;
          while (pos.getIndex() < pattern.length()) {
              final char c = pattern.charAt(pos.getIndex());
              switch (c) {
              case QUOTE:
                  appendQuotedString(pattern, pos, sb);
                  break;
              case START_FE:
                  depth++;
                  sb.append(START_FE).append(readArgumentIndex(pattern, next(pos)));
                  // do not look for custom patterns when they are embedded, e.g. in a choice
                  if (depth == 1) {
                      fe++;
                      final String customPattern = customPatterns.get(fe);
                      if (customPattern != null) {
                          sb.append(START_FMT).append(customPattern);
                      }
                  }
                  break;
              case END_FE:
                  depth--;
                  //$FALL-THROUGH$
              default:
                  sb.append(c);
                  next(pos);
              }
          }
          return sb.toString();
      }
docs: Insert formats back into the pattern for toPattern() support.
  
  @param pattern source
  @param customPatterns The custom patterns to re-insert, if any
  @return full pattern