1 Reply Latest reply on Apr 24, 2007 6:08 PM by fredatwork

    calendar timezones and database discrepancies

    fake fake Newbie

      Hey All,

      I am using EJB3 with hibernate on jboss 4.0.5. I'm testing my application with two different datasources - mysql 5 and oracle 10g.

      Ok, so i have an entity that i persist that has a date member of type Calendar. Here is the different functionality that i experience depending on datasource.

      On Oracle, if i specify the calendar's date to be noon localtime, and the timezone of the calendar to be local timezone, in the database the date column will be noon. If i change the timezone of the calendar to UTC, the date in the database is in my case (noon + 7 hours) (My current timezone is -7). This functionality makes sense and is what i expected. Since the column types that hibernate creates do not support timezone information, hibernate converts the date to the calendar's timezone before it stores the date.

      Using Mysql, the first scenario is the same. But if i change the calendar's timezone to UTC, mysql ignores it and the date stored is the same as the first.

      Does anyone know a way to get mysql to consider the timezone of the calendar like the oracle datasource does? Ultimately i would like to get my application to store dates in UTC instead of server localtime, which i can accomplish with oracle but not mysql, so thats my motivation here.

      Thanks for listening.