Cold
Cold

Reputation: 797

f:convertDateTime displays day and month inversed, and time 1 hour in past

I'm using convertDataTime to convert dates from a database. The problem that arises is that does not display dates correctly:

Example: In the database I have the date 09/10/2013 14:36:57 and it displays 10/09/2013 13:36:57.

Here is my code:

<p:dataTable ...>
                 ...
                 <p:column headerText="Data of sale">
                     <h:outputText value="#{faturaVar.dataEmissao}">
                         <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                     </h:outputText>
                 </p:column>
                 ...
</p:dataTable>

Att: I'm using primefaces 3.5, JPA / EJB.

Can anyone help?

Upvotes: 0

Views: 967

Answers (2)

Johnson Eyo
Johnson Eyo

Reputation: 113

in your managed bean or cdi bean add a method like this

 public TimeZone getTimeZone() {
return TimeZone.getDefault();
 }

 in the jsf ui <f:convertDateTime timeZone="#{bean.timeZone}" />

Upvotes: 0

Zaw Than oo
Zaw Than oo

Reputation: 9935

It is missing the timezone attribute in f:convertDateTime tag.

Update

There might be different timezone between DB Server and Application Server. Try to use timezone attribute in f:convertDateTime tag.

<f:convertDateTime pattern="dd/MM/yyyy hh:mm:ss" timezone="your-time-zone"/>

Upvotes: 1

Related Questions