I was just going through the Calendar API and the constant WEEK_OF_YEAR is defined as
Field number for get and set indicating the week number within the current year. The first week of the year, as defined by getFirstDayOfWeek() and getMinimalDaysInFirstWeek(), has value 1. Subclasses define the value of WEEK_OF_YEAR for days before the first week of the year.
I tried it out....
This was the output
Can someone please throw more light on this? I expected 52(or 53).
Well this week can be regarded as week 1. I wrote a Visual Basic program just yesterday for my work, and it turned out that it sees this week as week 53 and next week as week 2 - week 1 is completely missing.
I've writte a similar program as yours to test it:
The output is 2, 2, 4 and 1, and then it makes sense.
Monday is the first day of the week. Because of that, Thursday, Friday, Saturday and Sunday are all in this week, and are all in January. So the minimal days in the first week (4) has exactly been matched, and therefore this is week 1. [ December 30, 2008: Message edited by: Rob Prime ]