Calendar.getActualMaximum(Calendar.WEEK_OF_YEAR) weirdness

心不动则不痛 提交于 2019-12-05 13:39:57

This information is correct:

max:    52
actual: 53

The year 2010 has a maximum of 52 weeks. The actual week is 53, since 2009 has maximum 53 weeks and most weeks start on sunday or monday. Week 1 is in most cases the first week of the year with 4 days in january. Since the week of the january 1st has only 2 or 3 days in 2010, the week is considered part of 2009.

Most likely the english locale has different rules for determing week 1, like the first week is the week of january 1st.

Wikipedia explains it correctly: wikipedia week article

The problem is, that January 1st 2010 is in week 53 of 2009 (in Germany), but year 2010 only has 52 weeks (December 31st 2010 is in week 52). The Java Calendar object unfortunately does not have a field for the year, to which the week number relates.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!