开发者

JSF page reflects Date incorrectly - 1 Day shifted [duplicate]

This question already has an answer here: JSF convertDateTime renders the previous day (1 answer) 开发者_JS百科 Closed 7 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜