1

I have datetime in my DB. When I try to display it, the "hour" is wrong (6 hours more).

DB          2013-03-12 10:05:49
Display     2013/03/12 16:05:49

I'm using primefaces and this is the code:

<p:column id="fecha" headerText="Fecha" style="text-align: center">
  <h:outputText value="#{con.fecha}" >
    <f:convertDateTime pattern="yyyy/MM/dd HH:mm:ss"  />
  </h:outputText>
</p:column>

I tried to use the pattern HH, but it doesn't seem to work.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
user2161884
  • 11
  • 1
  • 1
  • 2

2 Answers2

7

in your web.xml try pasting these lines:

<context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
</context-param>
berkay
  • 3,907
  • 4
  • 36
  • 51
2

You are facing TimeZone issues...

I solved this problem getting my timeZone from here and changing the f:convertDateTime like this:

From

<f:convertDateTime pattern="yyyy/MM/dd HH:mm:ss"  />

To

<f:convertDateTime pattern="yyyy/MM/dd HH:mm:ss" timeZone="America/Montevideo" />

This is not fancy but it works.

A better solution you can find it here by adding this code into de web.xml

<context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
</context-param>
Community
  • 1
  • 1
Federico Traiman
  • 1,191
  • 1
  • 13
  • 18