Parsing inconsistent dates

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

Parsing inconsistent dates

Millies, Sebastian

Hello there, when parsing

 

DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss Z yyyy" );

DateTime dt = fmt.withLocale( Locale.US ).parseDateTime( "Friday 09 24 11:22:33 +02:00 2011" );

Date actual = dt.toDate();

 

I get back Fri Sep 23 11:22:33 CEST 2011

I might have expected Sat Sep 24 11:22:33 CEST 2011

 

The point is that actually September 23 is the Friday and September 24 the Saturday. Shouldn’t

parseDateTime have thrown an IllegalArgumentException or some such?

 

n  Sebastian

 

IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.softwareag.com


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
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 inconsistent dates

jodastephen
The parser interprets dates using a simple algorithm where it sets one field on top of another with no cross-checks like this. Changing this design is hard.

ThreeTen/JSR-310 is intended to have a parser that interprets things better.

Stephen


On 5 October 2011 09:33, Millies, Sebastian <[hidden email]> wrote:

Hello there, when parsing

 

DateTimeFormatter fmt = DateTimeFormat.forPattern( "E MM dd HH:mm:ss Z yyyy" );

DateTime dt = fmt.withLocale( Locale.US ).parseDateTime( "Friday 09 24 11:22:33 +02:00 2011" );

Date actual = dt.toDate();

 

I get back Fri Sep 23 11:22:33 CEST 2011

I might have expected Sat Sep 24 11:22:33 CEST 2011

 

The point is that actually September 23 is the Friday and September 24 the Saturday. Shouldn’t

parseDateTime have thrown an IllegalArgumentException or some such?

 

n  Sebastian

 

IDS Scheer Consulting GmbH
Geschäftsführer/Managing Directors: Kamyar Niroumand, Ivo Totev
Sitz/Registered office: Altenkesseler Straße 17, 66115 Saarbrücken, Germany - Registergericht/Commercial register: Saarbrücken HRB 19681
http://www.softwareag.com


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...