JSF page reflects the date incorrectly - 1 day shifted

DB value for date:

04-OCT-10 

Bean returns a method:

 Mon Oct 04 00:00:00 EEST 2010 

JSF returns:

 03.10.2010 

JSF Code:

 ... <h:outputText value="#{paym.dueDate}" > <f:convertDateTime pattern="dd.MM.yyyy"/> </h:outputText> ... 

What is the reason (s) that the JSF does not display the date correctly?

Thank you

+6
source share
2 answers

JSF date converters have a UTC time zone by default. But your date, apparently, is stored in the EEST time zone, which is several hours higher than UTC (more precisely, GMT + 3). When they enter these dates using the UTC time zone (as the default JSF), you will get the clock back in time and thus the previous day will be presented.

You need to explicitly specify the time zone in <f:convertDateTime> :

 <f:convertDateTime pattern="dd.MM.yyyy" timeZone="GMT+3" /> 
+18
source

Also consider this answer , which may be best suited for countries with different summer / winter time, and when your server’s time zone and jsf application’s time zone are such a time zone.

+1
source

Source: https://habr.com/ru/post/889820/


All Articles