要么我不理解方法getActualMaximum(int)或字段WEEK_OF_YEAR,或者涉及Sun bug(或全部三个)……有人可以向我解释为什么(至少在德国语言环境中……)以下内容码:
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 ));
产生以下输出:
max: 52
actual: 53
这是getActualMaximum(int)的Javadoc:
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.
编辑
情节变粗.在英语语言环境(-Duser.language = en -Duser.country = us)中,输出为:
max: 52
actual: 1
似乎指出它是德国语言环境的Sun bug?