I've a Spring Boot Web application using Thymeleaf as View Layer and I need to show some dates with a specific Timezone (CET = UTC+1/UTC+2).
The server is set for UTC and all dates are stored in my DB as datetime in UTC format too and that's fine.
Now I want to show this dates on my HTML pages not in UTC format but in CET using Thymeleaf Temporals but it seem doesn't work.
The date object is a Java Instant.
The retrieved date from DB is (for example) 2021-02-17T16:18:21Z and is display like:
<div th:text="${#temporals.format(user.lastAccess, 'dd/MM/yyyy HH:mm')}"></div>
=> 17/02/2021 16:18
But I want to show it like:
17/02/2021 17:18
so I used:
or
<div th:text="${#temporals.format(user.lastAccess, 'dd/MM/yyyy HH:mm', new java.util.Locale('it', 'IT'))}"></div>
But the date is always displayed as UTC
17/02/2021 16:18
The Java8TimeDialect for Thymeleaf is correctly configured.
I'm using:
Spring Boot 2.2.4
Thymeleaf 3.0.11.RELEASE
What am I doing wrong?
Thanks.