private String formatNumericTemporal(int value, Token token) {
    String output;
    if (token.temporalField == ChronoField.AMPM_OF_DAY) {
      output = value == 0 ? "a" : "p";
      output += token.string.length() == 2 ? "m" : ".m.";
      if (token.string.startsWith("A") || token.string.startsWith("P")) {
        output = output.toUpperCase();
      }
    } else { // it's a numeric value

      if (token.temporalField == ChronoField.HOUR_OF_AMPM && value == 0) {
        value = 12;
      }
      try {
        output = Integer.toString(value);
        output = padOrTruncateNumericTemporal(token, output);
      } catch (Exception e) {
        throw new IllegalArgumentException("Value: " + value + " could not be cast to string.", e);
      }
    }
    return output;
  }
Make sure the generated list of tokens is valid for formatting datetime objects to strings.
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java