normanj-bitquill commented on code in PR #3833:
URL: https://github.com/apache/calcite/pull/3833#discussion_r1667156649


##########
core/src/main/java/org/apache/calcite/util/format/postgresql/RomanNumeralMonthFormatPattern.java:
##########
@@ -81,4 +82,49 @@ public RomanNumeralMonthFormatPattern(boolean upperCase, 
String... patterns) {
       return romanNumeral.toLowerCase(locale);
     }
   }
+
+  @Override protected int parseValue(ParsePosition inputPosition, String 
input, Locale locale,
+      boolean haveFillMode, boolean enforceLength) throws Exception {
+    final String inputTrimmed = input.substring(inputPosition.getIndex());
+
+    if (inputTrimmed.startsWith(upperCase ? "III" : "iii")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 3);
+      return 3;
+    } else if (inputTrimmed.startsWith(upperCase ? "II" : "ii")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 2);
+      return 2;
+    } else if (inputTrimmed.startsWith(upperCase ? "IV" : "iv")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 2);
+      return 4;
+    } else if (inputTrimmed.startsWith(upperCase ? "IX" : "ix")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 2);
+      return 9;
+    } else if (inputTrimmed.startsWith(upperCase ? "I" : "i")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 1);
+      return 1;
+    } else if (inputTrimmed.startsWith(upperCase ? "VIII" : "viii")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 4);
+      return 8;
+    } else if (inputTrimmed.startsWith(upperCase ? "VII" : "vii")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 3);
+      return 7;
+    } else if (inputTrimmed.startsWith(upperCase ? "VI" : "vi")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 2);
+      return 6;
+    } else if (inputTrimmed.startsWith(upperCase ? "V" : "v")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 1);
+      return 5;
+    } else if (inputTrimmed.startsWith(upperCase ? "XII" : "xii")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 3);
+      return 12;
+    } else if (inputTrimmed.startsWith(upperCase ? "XI" : "xi")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 2);
+      return 11;
+    } else if (inputTrimmed.startsWith(upperCase ? "X" : "x")) {
+      inputPosition.setIndex(inputPosition.getIndex() + 1);
+      return 10;
+    }
+
+    throw new Exception();

Review Comment:
   Changed to a ParseException and added a message.



##########
core/src/main/java/org/apache/calcite/util/format/postgresql/TimeZoneHoursFormatPattern.java:
##########
@@ -29,14 +30,57 @@
  */
 public class TimeZoneHoursFormatPattern extends StringFormatPattern {
   public TimeZoneHoursFormatPattern() {
-    super("TZH");
+    super(ChronoUnitEnum.TIMEZONE_HOURS, "TZH");
   }
 
-  @Override String dateTimeToString(ZonedDateTime dateTime, boolean 
haveFillMode,
+  @Override protected int parseValue(final ParsePosition inputPosition, final 
String input,
+      final Locale locale, final boolean haveFillMode, boolean enforceLength) 
throws Exception {
+
+    int inputOffset = inputPosition.getIndex();
+    String inputTrimmed = input.substring(inputOffset);
+
+    boolean isPositive = true;
+    if (inputTrimmed.charAt(0) == '-') {
+      isPositive = false;
+    } else if (inputTrimmed.charAt(0) != '+') {
+      throw new Exception();

Review Comment:
   Changed to a ParseException and added a message.



-- 
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]

Reply via email to