Date ISO 8601 wrong week numbers
user21760 opened this issue · 1 comments
In ISO 8601 the first week of the year is the one with the first Thursday in it.
Currently, the date converter gives the week with 1 January in it as the week 1 in the output "ISO8601 Date (Weeks)", so, for years that starts in Friday, Saturday or Sunday, the week numbers of all the days are 1 week ahead and the first 3 days of the year are 1 year ahead.
Examples, the dates:
2016-12-31
2017-01-01
Output:
2016-W53-6T00:00:00Z
2017-W01-7T00:00:00Z
They should be:
2016-W52-6T00:00:00Z
2016-W52-7T00:00:00Z
I guess some lines need to be added in:
src/main/java/com/dencode/web/servlet/pages/DencodeServlet.java
Incorporating the format for week year (YYYY instead of yyyy) in the pattern string and setting the minimal days required in first week to 4 in the Calendar used by the DateFormat object.
Links to the methods in case they are indeed of help:
https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#setCalendar(java.util.Calendar)
https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#setMinimalDaysInFirstWeek(int)
Thank you for your detailed information.
I understand the cause of issue.
I'll fix it.