In comp.lang.java.programmer message <479ba463$0$90272$14726298@news.sun
site.dk>, Sat, 26 Jan 2008 16:21:42, Arne VajhHj <arne@vajhoej.dk>
posted:
Peter Rank wrote:
I want to display a String that contains the calendarweek and the
year. So I used the following format:
SimpleDateFormat weekFormat = new SimpleDateFormat("'KW' ww '/'
yyyy");
GregorianCalendar gc = new GregorianCalendar(2007,11,31);
System.out.println(weekFormat.format(gc.getTime()));
The result is: KW 01 / 2007
but what I would expect is: KW 53 / 2007 (KW 1 / 2008 would be okay
anyway)
Okay, ist's not quite difficult to code something to get the right
result, but ist there a solution that just uses the SimpleDateFormat-
Class to get the expected result?
Technically it is correct.
The week of the date is 1 (of year 2008) and the year of the
date is 2007.
That is incorrect : read ISO 8601 (via <URL:http://www.merlyn.demon.co.u
k/datefmts.htm>, if necessary.
new GregorianCalendar(2007,11,31)
is presumably 2007-12-31 in standard Gregorian notation, and it is
2008-W01-1 in standard Week notation.
Try read what people write before you accuse them of being incorrect.