Quantcast

Re: Parsing short timezones

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

Re: Parsing short timezones

Aaron Baff
I completely understand why you don't want to try and parse the Short Timezone names, but what about long ones like America/Los_Angeles? Why can't those be parsed? It would make it a LOT easier since I need to have the timezone which accounts for DST, and I always have been using the Long Name's. Currently I just have a REGEX that I use to parse out the bits and pieces, and then use them all individually to create the DateTime object.

--Aaron

>The JavaDoc for DateTimeFormat
> (http://joda-time.sourceforge.net/api-release/index.html) says "Zone
>names: Time zone names ('z') cannot be parsed" I'm not an expert, but
>I think this is because there are duplicates in the three-character
>time zone abbreviations. The "C" in CST could be Central, or it could
>be China.
>
>Whenever I need to read a zoned datetime, I use the zone id, "ZZZ".
>
>On Fri, Oct 15, 2010 at 12:41 PM, Dain Sundstrom <[hidden email]> wrote:
>> I'm having a problem parsing short timezones with the pattern 'zzz'.
>> For example, the following code throws an IllegalArgumentException:
>>
>> DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss zzz");
>> formatter.parseDateTime(formatter.print(new DateTime()));
>>
>>
>> java.lang.IllegalArgumentException: Invalid format: "10:40:00 PDT" is
>> malformed at "PDT"
>>        at >org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683)
>>        at >proofpoint.rep.whois.WhoIsParserTest.testTimeParser(WhoIsParserTest.java:19)
>>
>>
>> I'm using joda-time-1.6.2.jar
>>
>> Any idea what I'm doing wrong?
>>
>> Thanks,
>>
>> -dain
>>
>> -------------------------------------------------------------------------

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
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: Parsing short timezones

jodastephen
There is no reason why long time zone ids cannot be parsed, just that
it is code that no one ever wrote. To achieve it in JSR-310 required a
relatively complex trie type structure for efficient parsing. If you
want to write a patch against svn head with tests, feel free!
Stephen

On 29 November 2010 22:47, Aaron Baff <[hidden email]> wrote:

> I completely understand why you don't want to try and parse the Short Timezone names, but what about long ones like America/Los_Angeles? Why can't those be parsed? It would make it a LOT easier since I need to have the timezone which accounts for DST, and I always have been using the Long Name's. Currently I just have a REGEX that I use to parse out the bits and pieces, and then use them all individually to create the DateTime object.
>
> --Aaron
>
>>The JavaDoc for DateTimeFormat
>> (http://joda-time.sourceforge.net/api-release/index.html) says "Zone
>>names: Time zone names ('z') cannot be parsed" I'm not an expert, but
>>I think this is because there are duplicates in the three-character
>>time zone abbreviations. The "C" in CST could be Central, or it could
>>be China.
>>
>>Whenever I need to read a zoned datetime, I use the zone id, "ZZZ".
>>
>>On Fri, Oct 15, 2010 at 12:41 PM, Dain Sundstrom <[hidden email]> wrote:
>>> I'm having a problem parsing short timezones with the pattern 'zzz'.
>>> For example, the following code throws an IllegalArgumentException:
>>>
>>> DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss zzz");
>>> formatter.parseDateTime(formatter.print(new DateTime()));
>>>
>>>
>>> java.lang.IllegalArgumentException: Invalid format: "10:40:00 PDT" is
>>> malformed at "PDT"
>>>        at >org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:683)
>>>        at >proofpoint.rep.whois.WhoIsParserTest.testTimeParser(WhoIsParserTest.java:19)
>>>
>>>
>>> I'm using joda-time-1.6.2.jar
>>>
>>> Any idea what I'm doing wrong?
>>>
>>> Thanks,
>>>
>>> -dain
>>>
>>> -------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...