DEV Community


Discussion on: Dates are hard folks

shane profile image

With the Java Date formatter "YYYY" and "yyyy" have a very slight difference.
YYYY will give you the year belonging to the current week (whatever that means and is useful for). So sometimes around the end of the year things break.
So, the 31st of December 2020. That week technically belongs to the year 2021, so YYYY was returning 31st of December 2021 from our API while the database was correctly storing it as 31st of December 2020.

ALWAYS use 'yyyy'

ahferroin7 profile image
Austin S. Hemmelgarn

The 'YYYY' format is for week number dates (today is 2020-W32-5 per the ISO 8601 week date system). Week number dates are used a lot in manufacturing (or at least, the year and week number is, not the weekday as much) because that makes it easier to trace a given batch of products to a particular shift that was responsible for producing or checking them.