simhadri-g commented on code in PR #4777: URL: https://github.com/apache/hive/pull/4777#discussion_r1353244254
########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/InstantDateTimeFormatter.java: ########## @@ -25,15 +25,20 @@ import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.chrono.IsoEra; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; +import java.time.temporal.ChronoField; import java.util.Objects; final class InstantDateTimeFormatter extends InstantFormatterCache<DateTimeFormatter> { InstantDateTimeFormatter(final ZoneId zoneId) { super(zoneId, - s -> new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern(s).toFormatter().withZone(zoneId)); + s -> new DateTimeFormatterBuilder().parseCaseInsensitive() + .parseDefaulting(ChronoField.ERA, IsoEra.CE.getValue()) Review Comment: > Why are we setting defaults? In the new commit, this is reverted. The original reason for this was according to [java docs](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html), the symbols: - ` u` is `year ` - `y ` is `year-of-era ` So, when resolver style is set to Strict the patten `yyyy` is evaluated as year-of-era and would return null unless the era was specified. Hence ChronoField.ERA was set to "AD". Without this we would be limited to using the 'uuuu' pattern to represent year . -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org