-->
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: Hibernate MySQL Date problem
PostPosted: Sun Oct 19, 2008 1:06 am 
Newbie

Joined: Tue Nov 13, 2007 1:09 pm
Posts: 7
hi,

iam using java,hibernate,mysql


i am storing date which contains 19-10-2008 (of type java.sql.Date) (TIMEZONE GMT) to mysql DATE field.

but when i retrieve the same date from mysql to java by means of object it is being displayed as 18-10-2008 18:30:00 GMT :(

this is how the date property (of retrieved object) has mapped to hibernate type
<property name="pdate" type="date">
<column name="pdate" length="0" not-null="true" />
</property>
.



i could not able to figure out what is going wrong . can any one please guide me on What can go wrong in above scenario?


--rama


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 19, 2008 5:29 am 
Newbie

Joined: Tue Nov 13, 2007 1:09 pm
Posts: 7
i figured out the root cause of the problem and resolved the issue

1) Java TIME ZONE is GMT ------------------- storing DATE (2008-10-19 which is in GMT )

2) storing the above date in GMT to mysql

3) MYSQL TIME ZONE IS GMT+05:30

4) as mysql time zone is GMT+05:30 it is viewing the date as (2008-10-19) @ GMT+05:30

5) when i retrieved the date from mysql (GMT +05:30) -----------Java (GMT)
2008-10-19 @ GMT+05:30 ------------ 2008-10-18 18:30 (GMT)
converted to


the above is the reason why it is printing the previous day date.


Top
 Profile  
 
 Post subject: Re: Hibernate MySQL Date problem
PostPosted: Sat Jun 13, 2009 5:39 pm 
Newbie

Joined: Thu Feb 19, 2009 11:37 pm
Posts: 10
So how to fix it??


Top
 Profile  
 
 Post subject: Re: Hibernate MySQL Date problem
PostPosted: Mon Jun 15, 2009 3:23 am 
Beginner
Beginner

Joined: Fri Feb 13, 2009 5:27 am
Posts: 36
Location: India
HI...mlavannis

plz check following url regarding setting the timezone in mysql

http://stackoverflow.com/questions/9309 ... e-of-mysql

bye.tc.

_________________
parag


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.