private void verifyForParse() {

    // create a list of tokens' temporal fields
    List<TemporalField> temporalFields = new ArrayList<>();
    List<TemporalUnit> timeZoneTemporalUnits = new ArrayList<>();
    int roundYearCount=0, yearCount=0;
    boolean containsIsoFields=false, containsGregorianFields=false;
    for (Token token : tokens) {
      if (token.temporalField != null) {
        temporalFields.add(token.temporalField);
        if (token.temporalField == ChronoField.YEAR) {
          if (token.string.startsWith("r")) {
            roundYearCount += 1;
          } else {
            yearCount += 1;
          }
        }
        if (token.temporalField.isDateBased() && token.temporalField != ChronoField.DAY_OF_WEEK) {
          if (ISO_8601_TEMPORAL_FIELDS.contains(token.temporalField)) {
            containsIsoFields = true;
          } else {
            containsGregorianFields = true;
          }
        }
      } else if (token.temporalUnit != null) {
        timeZoneTemporalUnits.add(token.temporalUnit);
      }
    }

    //check for illegal temporal fields
    if (temporalFields.contains(IsoFields.QUARTER_OF_YEAR)) {
      throw new IllegalArgumentException("Illegal field: q (" + IsoFields.QUARTER_OF_YEAR + ")");
    }
    if (temporalFields.contains(WeekFields.SUNDAY_START.dayOfWeek())) {
      throw new IllegalArgumentException("Illegal field: d (" + WeekFields.SUNDAY_START.dayOfWeek() + ")");
    }
    if (temporalFields.contains(ChronoField.DAY_OF_WEEK) && containsGregorianFields) {
      throw new IllegalArgumentException("Illegal field: dy/day (" + ChronoField.DAY_OF_WEEK + ")");
    }
    if (temporalFields.contains(ChronoField.ALIGNED_WEEK_OF_MONTH)) {
      throw new IllegalArgumentException("Illegal field: w (" + ChronoField.ALIGNED_WEEK_OF_MONTH + ")");
    }
    if (temporalFields.contains(ChronoField.ALIGNED_WEEK_OF_YEAR)) {
      throw new IllegalArgumentException("Illegal field: ww (" + ChronoField.ALIGNED_WEEK_OF_YEAR + ")");
    }

    if (containsGregorianFields && containsIsoFields) {
      throw new IllegalArgumentException("Pattern cannot contain both ISO and Gregorian tokens");
    }
    if (!(temporalFields.contains(ChronoField.YEAR)
        || temporalFields.contains(IsoFields.WEEK_BASED_YEAR))) {
      throw new IllegalArgumentException("Missing year token.");
    }
    if (containsGregorianFields &&
        !(temporalFields.contains(ChronoField.MONTH_OF_YEAR) &&
            temporalFields.contains(ChronoField.DAY_OF_MONTH) ||
            temporalFields.contains(ChronoField.DAY_OF_YEAR))) {
      throw new IllegalArgumentException("""
          Missing day of year or (month of year + day of month)\
           tokens.\
          """);
    }
    if (containsIsoFields &&
        !(temporalFields.contains(IsoFields.WEEK_OF_WEEK_BASED_YEAR) &&
            temporalFields.contains(ChronoField.DAY_OF_WEEK))) {
      throw new IllegalArgumentException("Missing week of year (iw) or day of week (id) tokens.");
    }
    if (roundYearCount > 0 && yearCount > 0) {
      throw new IllegalArgumentException("""
          Invalid duplication of format element: Both year and\
          round year are provided\
          """);
    }
    for (TemporalField tokenType : temporalFields) {
      if (Collections.frequency(temporalFields, tokenType) > 1) {
        throw new IllegalArgumentException(
            "Invalid duplication of format element: multiple " + tokenType
                + " tokens provided.");
      }
    }
    if (temporalFields.contains(ChronoField.AMPM_OF_DAY) &&
        !(temporalFields.contains(ChronoField.HOUR_OF_DAY) ||
            temporalFields.contains(ChronoField.HOUR_OF_AMPM))) {
      throw new IllegalArgumentException("AM/PM provided but missing hour token.");
    }
    if (temporalFields.contains(ChronoField.AMPM_OF_DAY) &&
        temporalFields.contains(ChronoField.HOUR_OF_DAY)) {
      throw new IllegalArgumentException("Conflict between median indicator and hour token.");
    }
    if (temporalFields.contains(ChronoField.HOUR_OF_AMPM) &&
        temporalFields.contains(ChronoField.HOUR_OF_DAY)) {
      throw new IllegalArgumentException("Conflict between hour of day and hour of am/pm token.");
    }
    if (temporalFields.contains(ChronoField.DAY_OF_YEAR) &&
        (temporalFields.contains(ChronoField.DAY_OF_MONTH) ||
            temporalFields.contains(ChronoField.MONTH_OF_YEAR))) {
      throw new IllegalArgumentException("Day of year provided with day or month token.");
    }
    if (temporalFields.contains(ChronoField.SECOND_OF_DAY) &&
        (temporalFields.contains(ChronoField.HOUR_OF_DAY) ||
            temporalFields.contains(ChronoField.HOUR_OF_AMPM) ||
            temporalFields.contains(ChronoField.MINUTE_OF_HOUR) ||
            temporalFields.contains(ChronoField.SECOND_OF_MINUTE))) {
      throw new IllegalArgumentException(
          "Second of day token conflicts with other token(s).");
    }
    if (timeZoneTemporalUnits.contains(ChronoUnit.MINUTES) &&
        !timeZoneTemporalUnits.contains(ChronoUnit.HOURS)) {
      throw new IllegalArgumentException("Time zone minute token provided without time zone hour token.");
    }
  }
Make sure the generated list of tokens is valid for parsing strings to datetime objects.
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java