aspose file tools*
The moose likes Beginning Java and the fly likes Doubt : Calendar.WEEK_OF_YEAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Doubt : Calendar.WEEK_OF_YEAR" Watch "Doubt : Calendar.WEEK_OF_YEAR" New topic
Author

Doubt : Calendar.WEEK_OF_YEAR

Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
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

WEEK_OF_YEAR: 1


Can someone please throw more light on this? I expected 52(or 53).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

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 ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
makes sense. kind of.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Doubt : Calendar.WEEK_OF_YEAR