JSF page reflects Date incorrectly - 1 Day shifted [duplicate]
DB value of Date is:
04-OCT-10
Bean method returns:
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 reason(s),that JSF
displays Date value incorrectly?
thank you
The JSF date converters defaults to UTC timezone. But your date is apparently stored using EEST timezone which is some hours beyond UTC (GMT+3 to be precise). When intepreting those dates using UTC timezone (as JSF by default does), you will get hours back in time and thus the previous day will be represented.
You need to explicitly specify the timezone in <f:convertDateTime>
:
<f:convertDateTime pattern="dd.MM.yyyy" timeZone="GMT+3" />
Also consider This answer Which might be best suited for countries with different summer/winter time, and when both your server timezone and jsf app user timezone is such a timezone.
精彩评论