private boolean nextTokenIs(String pattern, Token currentToken) {
    // make sure currentToken isn't the last one
    final int idx = tokens.indexOf(currentToken);
    if (idx == tokens.size() - 1) {
      return false;
    }
    Token nextToken = tokens.get(idx + 1);
    pattern = pattern.toLowerCase();
    return (isTimeZoneToken(pattern) && TIME_ZONE_TOKENS.get(pattern) == nextToken.temporalUnit
        || isNumericTemporalToken(pattern) && NUMERIC_TEMPORAL_TOKENS.get(pattern) == nextToken.temporalField
        || isCharacterTemporalToken(pattern) && CHARACTER_TEMPORAL_TOKENS.get(pattern) == nextToken.temporalField);
  }
Does the temporalUnit/temporalField of the next token match the pattern's?
common/src/java/org/apache/hadoop/hive/common/format/datetime/HiveSqlDateTimeFormatter.java