Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Calendar

 
Phil Potter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings all,

I'm experiencing some strangeness when trying to persist a java.util.Calendar to a timestamp (on MySQL if it makes a difference).

The calendar's timezone is set up as GMT, however when it's persisted to the database the timezone appears to have changed to GMT+1 (I'm guessing BST).

I've done a bit of playing around with Date, which is meant to be time zone agnostic, however even when using a java.util.Date in my entity class, instead of the Calendar. I've also tried forcing the TimeZone on the Calendar to be something completely different, and playing with the Locale.

I'm at a bit of a loss as to what the cause is. Any pointers, tips, advice, or even solutions are most welcome!

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how MySQL will do it, but typically databases store dates in the same way as Java does: as a simple number. How do you test the value of the date? What timezone is the client you use to view the data configured to use?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic