Millies, Sebastian | 30 Jul 10:31 2011

DateTimeFormatter Bug parsing with general time zones in US Locale?

Hello there,

the DateTimeFormatter does not seem to be able to parse its own output in Joda 1.6.2.
Example:

Date date = new Date();
DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss z yyyy" );
DateTime dt = new DateTime( date );
String result = fmt.withLocale( Locale.US ).print( dt );

will yield "Sat 07 30 10:19:04 CEST 2011" on my machine (JDK 1.6, default Locale German).
However, feeding back that result into the DateTimeFormatter to parse:

DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss z yyyy" );
DateTime dt = fmt.withLocale( Locale.US ).parseDateTime( "Sat 07 30 10:19:04 CEST 2011");
Date date = dt.toDate();

will lead to
java.lang.IllegalArgumentException: Invalid format: "Sat 07 30 10:19:04 CEST 2011" is 
malformed at "CEST 2011"

I note that "CEST" is not part of the array returned by java.util.TimeZone.getAvailableIDs().
However, the corresponding JDK code will still work OK:

DateFormat df = new SimpleDateFormat( "E MM dd HH:mm:ss z yyyy", Locale.US );
Date date = df.parse( "Sat 07 30 10:19:04 CEST 2011" );

Am I overlooking something or is this really a bug? 

-- Sebastian
(Continue reading)

Stephen Colebourne | 30 Jul 10:33 2011

Re: DateTimeFormatter Bug parsing with general time zones in US Locale?

This is by design.

Short time zone names like CEST are not unique, so cannot be accurately parsed.

Stephen

On 30 July 2011 09:31, Millies, Sebastian
<Sebastian.Millies <at> softwareag.com> wrote:
> Hello there,
>
> the DateTimeFormatter does not seem to be able to parse its own output in Joda 1.6.2.
> Example:
>
> Date date = new Date();
> DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss z yyyy" );
> DateTime dt = new DateTime( date );
> String result = fmt.withLocale( Locale.US ).print( dt );
>
> will yield "Sat 07 30 10:19:04 CEST 2011" on my machine (JDK 1.6, default Locale German).
> However, feeding back that result into the DateTimeFormatter to parse:
>
> DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss z yyyy" );
> DateTime dt = fmt.withLocale( Locale.US ).parseDateTime( "Sat 07 30 10:19:04 CEST 2011");
> Date date = dt.toDate();
>
> will lead to
> java.lang.IllegalArgumentException: Invalid format: "Sat 07 30 10:19:04 CEST 2011" is
> malformed at "CEST 2011"
>
> I note that "CEST" is not part of the array returned by java.util.TimeZone.getAvailableIDs().
(Continue reading)

Millies, Sebastian | 30 Jul 11:01 2011

Re: DateTimeFormatter Bug parsing with general time zones in US Locale?

well yes, but why then are they output? I need a way to parse the output
of the formatter back to a date. And how does SimpleDateFormat manage?

--Sebastian

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne <at> joda.org] 
Sent: Saturday, July 30, 2011 10:33 AM
To: Discussion of the Joda project
Subject: Re: [Joda-interest] DateTimeFormatter Bug parsing with general time zones in US Locale?

This is by design.

Short time zone names like CEST are not unique, so cannot be accurately parsed.

Stephen


On 30 July 2011 09:31, Millies, Sebastian
<Sebastian.Millies <at> softwareag.com> wrote:
> Hello there,
>
> the DateTimeFormatter does not seem to be able to parse its own output in Joda 1.6.2.
> Example:
>
> Date date = new Date();
> DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss z yyyy" );
> DateTime dt = new DateTime( date );
> String result = fmt.withLocale( Locale.US ).print( dt );
>
(Continue reading)

Stephen Colebourne | 30 Jul 15:28 2011

Re: DateTimeFormatter Bug parsing with general time zones in US Locale?

Printers and parsers do not have to match, and since printing is
possible it is supported. Parsing is the problem.

I've added to git new methods in the builder that allow the caller to
pass in the mapping from String to zone. While this isn't the nicest
thing to have to do, it is the most reliable.

Stephe

On 30 July 2011 10:01, Millies, Sebastian
<Sebastian.Millies <at> softwareag.com> wrote:
> well yes, but why then are they output? I need a way to parse the output
> of the formatter back to a date. And how does SimpleDateFormat manage?
>
> --Sebastian
>
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne <at> joda.org]
> Sent: Saturday, July 30, 2011 10:33 AM
> To: Discussion of the Joda project
> Subject: Re: [Joda-interest] DateTimeFormatter Bug parsing with general time zones in US Locale?
>
> This is by design.
>
> Short time zone names like CEST are not unique, so cannot be accurately parsed.
>
> Stephen
>
>
> On 30 July 2011 09:31, Millies, Sebastian
(Continue reading)

Millies, Sebastian | 30 Jul 23:21 2011

Re: DateTimeFormatter Bug parsing with general time zones in US Locale?

oh, good. Which git would that be? (Sorry, I'm new to Joda.
I just cloned git://joda-time.git.sourceforge.net/gitroot/joda-time/joda-time,
but that doesn't seem to have the change.) 
-- Sebastian

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne <at> joda.org] 
Sent: Saturday, July 30, 2011 3:28 PM
To: Discussion of the Joda project
Subject: Re: [Joda-interest] DateTimeFormatter Bug parsing with general time zones in US Locale?

Printers and parsers do not have to match, and since printing is
possible it is supported. Parsing is the problem.

I've added to git new methods in the builder that allow the caller to
pass in the mapping from String to zone. While this isn't the nicest
thing to have to do, it is the most reliable.

Stephe


On 30 July 2011 10:01, Millies, Sebastian
<Sebastian.Millies <at> softwareag.com> wrote:
> well yes, but why then are they output? I need a way to parse the output
> of the formatter back to a date. And how does SimpleDateFormat manage?
>
> --Sebastian
>
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne <at> joda.org]
(Continue reading)

Stephen Colebourne | 31 Jul 10:20 2011

Re: DateTimeFormatter Bug parsing with general time zones in US Locale?

GitHub, the sourceforge one is an occasionally updated version
https://github.com/JodaOrg/joda-time
Stephen

On 30 July 2011 22:21, Millies, Sebastian
<Sebastian.Millies <at> softwareag.com> wrote:
> oh, good. Which git would that be? (Sorry, I'm new to Joda.
> I just cloned git://joda-time.git.sourceforge.net/gitroot/joda-time/joda-time,
> but that doesn't seem to have the change.)
> -- Sebastian
>
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne <at> joda.org]
> Sent: Saturday, July 30, 2011 3:28 PM
> To: Discussion of the Joda project
> Subject: Re: [Joda-interest] DateTimeFormatter Bug parsing with general time zones in US Locale?
>
> Printers and parsers do not have to match, and since printing is
> possible it is supported. Parsing is the problem.
>
> I've added to git new methods in the builder that allow the caller to
> pass in the mapping from String to zone. While this isn't the nicest
> thing to have to do, it is the most reliable.
>
> Stephe
>
>
> On 30 July 2011 10:01, Millies, Sebastian
> <Sebastian.Millies <at> softwareag.com> wrote:
>> well yes, but why then are they output? I need a way to parse the output
(Continue reading)


Gmane