Thanks for your reply. But what particular week started on Dec 26h 2004.
I guess it should be the last week of 2005.
Code:
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4
3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11
10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18
17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25
24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31
31
My Java program looks like this:
Code:
public static void calendarTest(){
Locale.setDefault(Locale.GERMAN);
//Locale.setDefault(Locale.UK);
//Locale.setDefault(Locale.US);
for (int date=25; date <=27; ++ date) {
int year = 2004, month = 11;
Calendar cal = new GregorianCalendar(year, month, date);
DateFormat sdf = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
DateFormat df = new SimpleDateFormat("yyyyww");
System.out.println("Date: " + sdf.format(cal.getTime())
+ " Week:" + df.format(cal.getTime()));
}
}
If you try different locales, you get fairly different results. If you try the GERMAN Locale you get:
Code:
Date: 25.12.04 Week:200452
Date: 26.12.04 Week:200452
Date: 27.12.04 Week:200453
The US Locale gives:
Code:
Date: 12/25/04 Week:200452
Date: 12/26/04 Week:200401
Date: 12/27/04 Week:200401
So i wonder if really the first week of 2005 started on Dec, 26th. The UK Locale differs from
the US locale that the week starts on Monday instead of sunday. But It also starts the 'new
year' in december.
I did not check the ISO standard for week calculation for now. But i think the weeks
are defined there as starting on monday.