thymeleaf / thymeleaf-extras-java8time

Thymeleaf "extras" dialect for formatting and creating Java 8 Time API objects
Apache License 2.0
105 stars 34 forks source link

Incorrect formatted date #27

Closed jamesdbaker closed 5 years ago

jamesdbaker commented 5 years ago

I have a LocalDate object. If this is set to 2019-12-30 or 2019-12-31, then the following formatting shows the incorrect date (notice the year):

<p th:text="${#temporals.format(event.deadline, 'dd MMM YYYY')}"></p>

Gives 30 Dec 2020 and 31 Dec 2021 respectively. The adjacent dates give 29 Dec 2019 and 01 Jan 2020 as expected.

I am using Spring Boot 1.5.22.RELEASE, which uses thymeleaf-extras-java8time 2.1.0.RELEASE.

jmiguelsamper commented 5 years ago

I think you should use yyyy for the year pattern instead of YYYY, please see https://stackoverflow.com/questions/8686331/y-returns-2012-while-y-returns-2011-in-simpledateformat