mettok
mettok

Reputation: 557

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>

Upvotes: 0

Views: 4488

Answers (2)

Daniel
Daniel

Reputation: 37051

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 ...

Upvotes: 10

Ilan Tal
Ilan Tal

Reputation: 499

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.

Upvotes: 0

Related Questions