File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt : Calendar.WEEK_OF_YEAR

 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
makes sense. kind of.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic