Dateformat ww returns wrong week of year

Viewed 75
1 Answers

You can use week(Date) instead of trying dateformat.

I am not sure why dateformat is taking the last week of 2019 as the first week of 2020. Most likely dateformat is not designed to handles these nuanced logics. Since Week function is must be specifically designed for this purpose it would be wise to make use of that. I'll update the answer if I can find anything specific to suggest the reason for dateformat issue.

Update from comment by @Agreax :

Week() uses Adobe's internal logic. DateFormat() uses java's SimpleDateFormat class which ".. depends on the values of getMinimalDaysInFirstWeek(), getFirstDayOfWeek(), and the day of the week of January 1..". With the default settings, 12/30/2019 is considered part of the 1st week of 2020.

Related