This must be so trivial...and yet...

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

This must be so trivial...and yet...

BenoitX
Administrator
Hi *,

I'm sorry to post this trivial question but my head is about to explode...

I store LocalTime in my DB using org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime which stores it as a Time in UTC.

I sometime needs to display that value in a given time zone.

Say in my DB I have 17:45 UTC.
And a String that says "Europe/Paris"

How could I get a LocalTime that shows 18:45 (local time in Paris)...

I need to convert the LocalTime to a java.util.Date for a widget that we're using.

I have tried this:
localTime.toDateTimeToday(DateTimeZone.forID("Europe/Paris"))
But that returns a time of 16:45, not 18:45... WHY?  How can I display 18:45?


Eventually, if the user enter 19:15 in that widget, I then need to assume it is 19:15 in Paris time and need to convert that to a UTC time.

Many thanks!

And, again sorry but I'm getting very confused!

Benoit
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: This must be so trivial...and yet...

Stephen Cresswell
Try this...

        LocalTime t = new LocalTime(17, 45)
        println t.toDateTimeToday(DateTimeZone.UTC).toDateTime(DateTimeZone.forID('Europe/Paris'))

2008/12/15 BenoitX <[hidden email]>

Hi *,

I'm sorry to post this trivial question but my head is about to explode...

I store LocalTime in my DB using
org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime which stores it as
a Time in UTC.

I sometime needs to display that value in a given time zone.

Say in my DB I have 17:45 UTC.
And a String that says "Europe/Paris"

How could I get a LocalTime that shows 18:45 (local time in Paris)...

I need to convert the LocalTime to a java.util.Date for a widget that we're
using.

I have tried this:
localTime.toDateTimeToday(DateTimeZone.forID("Europe/Paris"))
But that returns a time of 16:45, not 18:45... WHY?  How can I display
18:45?


Eventually, if the user enter 19:15 in that widget, I then need to assume it
is 19:15 in Paris time and need to convert that to a UTC time.

Many thanks!

And, again sorry but I'm getting very confused!

Benoit
--
View this message in context: http://n2.nabble.com/This-must-be-so-trivial...and-yet...-tp1656210p1656210.html
Sent from the Joda-Interest mailing list archive at Nabble.com.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...