Monday, December 29, 2014

ISO 8601 week numbering need correct date format to be specified

Since year 2015 starts on a Thursday, many of the programs which rely on epoch calculation returns the start of the year as monday of the week since the year starts on a thursday. So the start of the year 2015 is actually today, i.e, monday Dec 29th, 2014. You can use the below link for epoch conversion:-

epoch convertor

You can see the difference in format when you run the "date" command on linux machines:-

$ date
Mon Dec 29 20:14:41 EST 2014

$ date -u "+%Y"
2014

$ date -u "+%G"
2015

You can see the same behavior with the below

..
Format f = new SimpleDateFormat("yyyy");
System.out.println("year : " + f.format(new Date()));
..

returns "2014", whereas

...
Format f = new SimpleDateFormat("YYYY");
System.out.println("year : " + f.format(new Date()));
...

returns "2015", so we have to check our scripts and programs to see if we are using the correct format string for returning dates (i.e., not use YYYY or %G)

No comments:

Post a Comment