Either I don't understand the method
getActualMaximum(int) or the field WEEK_OF_YEAR, or there's a Sun bug involved (or all three)...could someone explain to me why (at least in a German locale...) the following code:
Locale.setDefault( Locale.GERMAN ); Calendar c = Calendar.getInstance(); c.set( Calendar.YEAR, 2010 ); c.set( Calendar.MONTH, 0 ); c.set( Calendar.DAY_OF_MONTH, 1 ); System.out.println("max: "+c.getActualMaximum( Calendar.WEEK_OF_YEAR )); System.out.println("actual: "+c.get( Calendar.WEEK_OF_YEAR ));
produces the following output:
max: 52 actual: 53
Here's the Javadoc of
Returns the maximum value that the specified calendar field could have, given the time value of this Calendar. For example, the actual maximum value of the MONTH field is 12 in some years, and 13 in other years in the Hebrew calendar system.
The plot thickens. In an English locale (
-Duser.language=en -Duser.country=us) the output is:
max: 52 actual: 1
Seems to point to it being a Sun bug for German locales?