private int parseCharacterTemporal(String substring, Token token) {
    try {
      if (token.temporalField == ChronoField.MONTH_OF_YEAR) {
        if (token.length == 3) {
          return Month.from(MONTH_FORMATTER.parse(capitalize(substring))).getValue();
        } else {
          return Month.valueOf(substring.toUpperCase()).getValue();
        }
      } else if (token.temporalField == ChronoField.DAY_OF_WEEK) {
        if (token.length == 3) {
          return DayOfWeek.from(DAY_OF_WEEK_FORMATTER.parse(capitalize(substring))).getValue();
        } else {
          return DayOfWeek.valueOf(substring.toUpperCase()).getValue();
        }
      }
    } catch (Exception e) {
      throw new IllegalArgumentException(
          "Couldn't parse substring \"" + substring + "\" with token " + token + " to integer."
              + "Pattern is " + pattern, e);
    }
    throw new IllegalArgumentException(
        "token: (" + token + ") isn't a valid character temporal. Pattern is " + pattern);
  }
Get the integer value of a numeric temporal substring.

@param substring the next parseable substring of the input string
@param token Token representing the next element of the pattern
@return int value of temporal
@throws IllegalArgumentException if substring is not parseable or if its value is outside of
token's allowed range (e.g. token is hh/hh12 (range: 1-12) and substring is "0")
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java