Either I do not understand the getActualMaximum(int) method, or the WEEK_OF_YEAR field, or there is a Sun error (or all three) ... can someone explain to me why (at least in the 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 ));
outputs the following result:
max: 52 actual: 53
Here's the Javadoc getActualMaximum(int) :
Returns the maximum value that the specified calendar field can 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 Jewish calendar system.
Edit
The plot is thickening. In the English locale ( -Duser.language=en -Duser.country=us ) the output is:
max: 52 actual: 1
Does it seem to indicate that this is a Sun bug for German locales?
source share