In my Postgresql database, I have a timestamp without time zone with this value : "2012-06-15 17:49:46.423" (default datatype used by Hibernate).
If I format with SimpleDateFormat and this pattern "EEEE dd MMMM yyyy", SimpleDateFormat#format returns “jeudi 14 juin 2012”.
Why the result is not “vendredi 15 juin 2012” ?
French to English translation for non-french spoken :
"jeudi 14 juin 2012" => "Thursday 14th of June 2012"
"vendredi 15 juin 2012" => "Friday 15th of June 2012"
Hibernate 3.6.8.Final
JSF 2.0
JBoss 5.1.0.GA
Java 6
Thanks.
After searching, it turns out that I had two main options. Either I set the time zone through Hibernate or JSF.
Option 1 : Hibernate
I could change access type to Property. So in the setter, I would adjust the timestamp value to the right time zone. Another solution would be to create a custom Hibernate User Type.
Full details with code here : Mapping Dates and Time Zones with Hibernate, Part 2: Few Solutions
Option 2 : JSF
Last option, I either create a
custom converterin JSF or more simply, I use the timeZone attribute off:convertDateTime.This how I did it :
All my dates are correct now !
Source (in french) : Comment utiliser le timezone du compensant JSF convertDateTime