private int parseSeparator(String fullInput, int index, Token token) {
    int begin = index;
    String s;
    StringBuilder separatorsFound = new StringBuilder();

    while (index < fullInput.length() &&
        VALID_SEPARATORS.contains(fullInput.substring(index, index + 1))) {
      s = fullInput.substring(index, index + 1);
      if (!isLastCharacterOfSeparator(index, fullInput)
          || !("-".equals(s) && (nextTokenIs("tzh", token)))
          || separatorsFound.length() == 0) {
        separatorsFound.append(s);
      }
      index++;
    }

    if (separatorsFound.length() == 0) {
      throw new IllegalArgumentException("Missing separator at index " + index);
    }
    if (formatExact && !token.string.equals(separatorsFound.toString())) {
      throw new IllegalArgumentException("FX on and separator found: " + separatorsFound
          + " does not match expected separator: " + token.string);
    }

    return begin + separatorsFound.length();
  }
Parse the next separator(s). At least one separator character is expected. Separator
characters are interchangeable.

Caveat: If the last separator character in the separator substring is "-" and is immediately
    followed by a time zone hour (tzh) token, it's a negative sign and not counted as a
    separator, UNLESS this is the only separator character in the separator substring (in
    which case it is not counted as the negative sign).

@throws IllegalArgumentException if separator is missing or if FX is on and separator doesn't
match the expected separator pattern exactly
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java