RE-EDITED
I have a bean with a field "lastUpdate", which is of type Date, and its usual getter/setter. I use JPA to persist my beans into a PostGreSql DB.
I want to have my lastUpdate be saved in UTC, so before setting it, I set the time zone:
Calendar calendar = DatatypeConverter.parseDateTime( text.toString() );
calendar.setTimeZone( TimeZone.getTimeZone( "Europe/Zurich" ) );
doiPool.setLastUpdate( calendar.getTime() );
So, if lastUpdate is "2013-08-02 12:17:05" (Europe/Zurich), in the DB I have "2013-08-02 10:17:05" (UTC), which is what I want.
When I display the date back, I also want to have it according to my time zone, so I thought I could use the f:convertDateTime and setting the timeZone="xxx".
...
<f:facet name="header"> #{msg.dashboardColumnLastUpdate} </f:facet>
<h:outputText value="#{dashboardDoiPoolRow.doiPool.lastUpdate}">
<f:convertDateTime pattern="yyyy-MM-dd HH:mm" timeZone="Europe/Zurich"/>
</h:outputText>
...
Reading other answers, I tried to set the
javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE
too, but the result is always the same: by displaying the date I get 2013-08-02 10:17:05 instead 2013-08-02 12:17:05.
I think that if the converter does its job correctly, if I want to display 2013-08-02 10:17:05 (UTC) according my time zone, setting the time zone to mine (Europe/Zurich), I should get 2013-08-02 12:17:05
Do I miss something??
In the DB, the column is of type "timestamp without time zone". Does it have some effect?