How to parse date/time with time zone?

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

How to parse date/time with time zone?

David Hoffer
I need to parse date/time strings like:

Sat Mar 03 13:57:33 EST 2007

However in using JodaTime although it supports a format character (z)
for the EST time zone it doesn't work, it fails at EST every time.  It
seems the format character (z/Z) is ignored.

How can I parse this with JodaTime?  Will this work using the JDK parser?

-Dave

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to parse date/time with time zone?

jodastephen
The 'EST' cannot be parsed using Joda-Time as the zone is ambiguous. You
can parse it using the JDK.
Stephen


David Hoffer wrote:

> I need to parse date/time strings like:
>
> Sat Mar 03 13:57:33 EST 2007
>
> However in using JodaTime although it supports a format character (z)
> for the EST time zone it doesn't work, it fails at EST every time.  It
> seems the format character (z/Z) is ignored.
>
> How can I parse this with JodaTime?  Will this work using the JDK parser?
>
> -Dave
>
> ------------------------------------------------------------------------------
> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to parse date/time with time zone?

Stephen Cresswell
In reply to this post by David Hoffer
or providing you are only ever parsing EST you can do something like...

        DateTimeZone EST = DateTimeZone.forID('EST')
        DateTimeFormatter dtf = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss 'EST' yyyy").withZone(EST)
        DateTime parsed = dtf.parseDateTime('Sat Mar 03 13:57:33 EST 2007')



2008/12/13 David Hoffer <[hidden email]>
I need to parse date/time strings like:

Sat Mar 03 13:57:33 EST 2007

However in using JodaTime although it supports a format character (z)
for the EST time zone it doesn't work, it fails at EST every time.  It
seems the format character (z/Z) is ignored.

How can I parse this with JodaTime?  Will this work using the JDK parser?

-Dave

------------------------------------------------------------------------------
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...