-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Calendar inserting GMT instead of local timezone of GMT-5
PostPosted: Wed Jan 03, 2007 3:51 pm 
Beginner
Beginner

Joined: Sun Nov 16, 2003 3:04 pm
Posts: 24
Hibernate version: 3

Name and version of the database you are using: Informix

Here's a snippet of the code fragment I'm using:
Code:
    @Id
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "ROW_UPD_TS")
    public Calendar getRowUpdate()
    {
        return rowUpdate;
    }


The Informix DDL to insert the row is:
Code:
       ROW_UPD_TS           datetime year to minute NOT NULL,


To get the current time, I use this piece of code:

Code:
    public static Calendar getCurrentCalendar()
    {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        return cal;
    }


(I pull off the second and millisecond, because I save several rows at a time, which can take a few seconds, and getRowUpdate is part of the ID)

Now, I'm capable of persisting the object, and it persists everything just fine. However, it is persisting the data 5 hours later than what the current time is. Its saving it in GMT vs GMT-5 like it should.

I checked the timestamp of all the computers (including the DB server, webserver, appserver, and my local machine for test cases), and every made test cases for them to display the time after I create a calendar, and all of them are providing the correct time, yet when it goes through hibernate and saves, the saved value is in GMT. Is there a default within EJB3 or Hibernate3 that uses GMT? If so, can it be turned off??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 8:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is probably a bug of your driver.
To work around it you can use a @Type, which do the "unatural" conversion.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 04, 2007 1:45 pm 
Beginner
Beginner

Joined: Sun Nov 16, 2003 3:04 pm
Posts: 24
I tried the Type without success. Same thing happened. When I switched from Calendar to (java.util.)Date, it worked fine, though. Wierd.

Thanks anyway!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 06, 2007 12:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
in your usertype code, you have to do the unnatural conversion

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.