Java Date year calculation is off by year for two days

This is the problem:

"dd-MMM-YYYY"

YYYY is the week-year, not the calendar year. You want yyyy instead.

The last two days of calendar year 2012 were in the first week of week-year 2013. You should normally only use the week year in conjunction with the “week of year” specifier (w).

Leave a Comment