Persisting Joda DateTime instead of Java Date in hibernate

Posted by Tauren on Stack Overflow See other posts from Stack Overflow or by Tauren
Published on 2010-02-03T02:05:03Z Indexed on 2010/04/30 22:57 UTC
Read the original article Hit count: 444

Filed under:
|
|
|

My entities currently contain java Date properties. I'm starting to use Joda Time for date manipulation and calculations quite frequently. This means that I'm constantly having to convert my Dates into Joda DateTime objects and back again.

So I was wondering, is there any reason I shouldn't just change my entities to store Joda DateTime objects instead of Java Date objects?

Please note that these entities are persisted via Hibernate. I found the jodatime-hibernate project, but I also was reading on the Joda mailing list that it wasn't compatible with newer versions of hibernate. And it seems like it isn't very well maintained.

So I'm wondering if it would be best to just continue converting between Date and DateTime, or if it would be wise to start persisting DateTime objects. My concern is being reliant on a poorly maintained library.

Edit: Note that one of my objectives is to be better able to store timezone information. Storing just a Date appears to save the date in the local timezone. As my application can be used globally, I need to know the timezone as well. Joda Time Hibernate seems to address this as well in the user guide.

© Stack Overflow or respective owner

Related posts about jodatime

Related posts about hibernate