简体   繁体   中英

date and time in java with <f:convertDateTime/>

I am developing an application using spring webflow and primefaces and use mysql. The problem is when i register the date for example 15.may. 2012. it register correct in database but when i display it. it shows one day before 14.may.2012. I use this tag to display the date and I believe that which add 1 day to the displayed date. Another thing which i remarked is that when i debug i see the time displays like this Wed May 09 00:00:00 CEST. Which i believe is in Central European Summer timezone . I would like to know what the problem is?

<p:column headerText="Submited Date">
    <h:outputText value="#{item.submitedDate}">
         <f:convertDateTime pattern="dd-MMM-yyyy" ></f:convertDateTime>
    </h:outputText>
</p:column>

try adding

<context-param> 
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</p‌​aram-name> 
    <param-value>true</param-value> 
</context-param> 

to your web.xml the param-name is self explanatory ...

On the timezone I found this

This attribute sets the time zone for which to interpret date/time information. The value must be either a value-binding expression that evaluates to a java.util.TimeZone instance, or a String that is a timezone ID as per the Java API documentation for java.util.TimeZone.getTimeZone().

It isn't clear why the date is shifted by one day.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM