Year increments by 1 when changing date format in Jaspersoft
search cancel

Year increments by 1 when changing date format in Jaspersoft

book

Article ID: 242264

calendar_today

Updated On:

Products

Clarity PPM On Premise Clarity PPM SaaS

Issue/Introduction

The year of a date increments by 1, when the date format is changed to "dd MMM YYYY". For example, if the date before changing the format is "12/26/2021", after changing the format, it converts to "26 Dec 2022". This is noticed in Adhoc Views. Why does this happen?

Resolution

This is working as expected since "Y" (upper case Y) is interpreted as the "Week Year" by Java. Whereas, "y" (lower case Y) is interpreted as the "Year". It is the upper case Y that is used by Adhoc Views when the format "dd MM YYYY" is selected in the front end.

In the example above, since 26th of December of 2021 is within the first week of 2022, the year that is returned is 2022.

In comparison, 25th of December 2021 does not share a week with 2022. So, the year returned is 2021.

Additional Information

Oracle Docs: