Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 433
sergionni Avatar asked Jun 05 '11 15:06

sergionni


2 Answers

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" />
like image 97
BalusC Avatar answered Nov 09 '22 05:11

BalusC


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.

like image 1
otonglet Avatar answered Nov 09 '22 05:11

otonglet