gregorian calendar ambiguity

Dear friends,

I have problem in using GeregorianCalendar for last week of year if the week isn't complete.

GregorianCalendar gc =new GregorianCalendar(2007,11,31);

assertEquals(gc.get(WEEK_OF_YEAR), 52);// failed !!

assertEquals(gc.get(WEEK_OF_YEAR), 1);// success !!

Thanks for your help.

[427 byte] By [seyyedjamala] at [2007-11-27 0:26:02]
# 1

Quote from

http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html

Values calculated for the WEEK_OF_YEAR field range from 1 to 53. Week 1 for a year is the earliest seven day period starting on getFirstDayOfWeek() that contains at least getMinimalDaysInFirstWeek() days from that year. It thus depends on the values of getMinimalDaysInFirstWeek(), getFirstDayOfWeek(), and the day of the week of January 1. Weeks between week 1 of one year and week 1 of the following year are numbered sequentially from 2 to 52 or 53 (as needed).

Does this help you ?

rym82a at 2007-7-11 22:24:13 > top of Java-index,Java Essentials,Java Programming...