Jackie-Jiang commented on code in PR #8792:
URL: https://github.com/apache/pinot/pull/8792#discussion_r883877467
##########
pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatPatternSpec.java:
##########
@@ -81,6 +82,23 @@ public DateTimeFormatter getDateTimeFormatter() {
return _dateTimeFormatter;
}
+ /**
+ * Validates the sdf pattern
+ */
+ public static void validateFormat(@Nonnull String sdfPatternWithTz) {
+ String sdfPattern;
+ DateTimeZone dateTimeZone = DEFAULT_DATETIMEZONE;
+ Matcher m = SDF_PATTERN_WITH_TIMEZONE.matcher(sdfPatternWithTz);
+ if (m.find()) {
+ sdfPattern = m.group(SDF_PATTERN_GROUP).trim();
+ String timezoneString = m.group(TIMEZONE_GROUP).trim();
+ dateTimeZone =
DateTimeZone.forTimeZone(TimeZone.getTimeZone(timezoneString));
+ } else {
+ sdfPattern = sdfPatternWithTz;
+ }
+ DateTimeFormat.forPattern(sdfPattern).withZone(dateTimeZone);
Review Comment:
Suggest wrapping it in a try-catch, and put some useful exception message
such as `"Invalid SDF pattern: " + sdfPatternWithTz` for user to better
understand the issue
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]