sebbASF commented on code in PR #408:
URL: https://github.com/apache/commons-validator/pull/408#discussion_r3477903634


##########
src/main/java/org/apache/commons/validator/routines/AbstractCalendarValidator.java:
##########
@@ -416,4 +422,14 @@ protected Object parse(String value, final String pattern, 
final Locale locale,
      */
     @Override
     protected abstract Object processParsedValue(Object value, Format 
formatter);
+
+    /**
+     * Returns the week-year of a calendar, which a {@code WEEK_OF_YEAR} value 
is relative to.
+     *
+     * @param calendar The calendar to read the week-year from.
+     * @return the week-year, or the calendar year if week dates are not 
supported.
+     */
+    private int weekYear(final Calendar calendar) {
+        return calendar.isWeekDateSupported() ? calendar.getWeekYear() : 
calendar.get(Calendar.YEAR);
+    }

Review Comment:
   I’m not sure it makes sense to return the YEAR here. AFAICT this effectively 
converts a WEEK_OF_YEAR comparison into a YEAR comparison. It might make more 
sense to throw instead.



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