private void checkFormatExact(String substring, Token token) {
    // AM/PM defaults to length 4 but make it 2 for FX check if the pattern actually has length 2
    if (formatExact && token.temporalField == ChronoField.AMPM_OF_DAY) {
      token.length = token.string.length();
    }
    if (formatExact
        && !(token.fillMode || token.temporalField == ChronoField.NANO_OF_SECOND)
        && token.length != substring.length()) {
      throw new IllegalArgumentException(
          "FX on and expected token length " + token.length + " for token " + token
              + " does not match substring (" + substring + ") length " + substring.length());
    }
  }
@throws IllegalArgumentException if input length doesn't match expected (token) length
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java