Joda-Time Hibernate, local dates, and time zones

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Joda-Time Hibernate, local dates, and time zones

Mark Carroll
PersistentLocalDate seems to persist different things into the DB for
the same LocalDate depending on what Joda's default time zone is set to,
which seems wrong. I don't want to have to be sure it's set to the same
thing when I'm reading the LocalDates back in, and I'm not sure even
that's enough to survive the problem. Should the conversion to a Date
via toDateMidnight or toDateTimeAtStartOfDay perhaps be done with
respect to UTC or something instead of whatever the current default
happens to be? Or is there some other LocalDate persister I should be
using if I want my LocalDates to survive changes in the default time zone?

Or perhaps I'm just completely misunderstanding everything and some kind
person can put me straight. (-: Perhaps I have a broken JDBC layer or
something.

By the way,
http://joda-time.sourceforge.net/contrib/hibernate/userguide.html 
suggests it persists LocalDates with TIMESTAMPs but it actually seems to
be using DATEs. I don't know if that means I'm doing something wrong or
if the documentation is incorrect. (I'm using PostgreSQL if that's
relevant.)

Mark

--
Mark Carroll
Software Engineer
[hidden email]
http://www.vecna.com/

Cambridge Research Laboratory
Vecna Technologies, Inc.
36 Cambridge Park Drive
Cambridge, MA 02140
Phone: (617) 864-0636
Fax: (617) 864-0638

Better Technology, Better World (TM)

The contents of this message may be privileged and confidential.
Therefore, if this message has been received in error, please delete it
without reading it. Your receipt of this message is not intended to
waive any applicable privilege. Please do not disseminate this message
without the permission of the author.

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Joda-Time Hibernate, local dates, and time zones

jodastephen
I wouldn't be surprised if this was the case and that it is weird.
I've now added a link to the usertype project from the JT hibernate
home page to try and persuade users to migrate. I suspect you may find
that library works better for your use case!

Stephen



On 18 August 2011 20:05, Mark Carroll <[hidden email]> wrote:

> PersistentLocalDate seems to persist different things into the DB for
> the same LocalDate depending on what Joda's default time zone is set to,
> which seems wrong. I don't want to have to be sure it's set to the same
> thing when I'm reading the LocalDates back in, and I'm not sure even
> that's enough to survive the problem. Should the conversion to a Date
> via toDateMidnight or toDateTimeAtStartOfDay perhaps be done with
> respect to UTC or something instead of whatever the current default
> happens to be? Or is there some other LocalDate persister I should be
> using if I want my LocalDates to survive changes in the default time zone?
>
> Or perhaps I'm just completely misunderstanding everything and some kind
> person can put me straight. (-: Perhaps I have a broken JDBC layer or
> something.
>
> By the way,
> http://joda-time.sourceforge.net/contrib/hibernate/userguide.html
> suggests it persists LocalDates with TIMESTAMPs but it actually seems to
> be using DATEs. I don't know if that means I'm doing something wrong or
> if the documentation is incorrect. (I'm using PostgreSQL if that's
> relevant.)
>
> Mark
>
> --
> Mark Carroll
> Software Engineer
> [hidden email]
> http://www.vecna.com/
>
> Cambridge Research Laboratory
> Vecna Technologies, Inc.
> 36 Cambridge Park Drive
> Cambridge, MA 02140
> Phone: (617) 864-0636
> Fax: (617) 864-0638
>
> Better Technology, Better World (TM)
>
> The contents of this message may be privileged and confidential.
> Therefore, if this message has been received in error, please delete it
> without reading it. Your receipt of this message is not intended to
> waive any applicable privilege. Please do not disseminate this message
> without the permission of the author.
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...