Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Unparsable date with a valid ISO 8601 date #1434

Open
gionn opened this issue Mar 18, 2013 · 3 comments
Open

Unparsable date with a valid ISO 8601 date #1434

gionn opened this issue Mar 18, 2013 · 3 comments

Comments

@gionn
Copy link

gionn commented Mar 18, 2013

Hi,

I was trying the EC2 driver against the OpenNebula EC2 implementation, and I am getting errors parsing dates:

Caused by: java.text.ParseException: Unparseable date: "2013-02-14T17:53:20+0100"
at java.text.DateFormat.parse(DateFormat.java:354)
at org.jclouds.date.internal.SimpleDateFormatDateService.iso8601DateParse(SimpleDateFormatDateService.java:154)

The code I am using: https://gist.github.com/gionn/49ae4cd76f07ceac55f5
jclouds 1.5.8

AFAIK the date should be in ISO 8601 format (it is generated using the standard Ruby Time implementation)

Thanks.

@demobox
Copy link
Member

demobox commented Mar 18, 2013

Hi Giovanni

It looks like the wrong parsing method is being called. iso8601DateParse is fine with the following input:

new SimpleDateFormatDateService().iso8601DateParse("2013-02-14T17:53:20.000+0100");

(note the milliseconds) but does indeed not like your input (accurate to seconds only). See iso8601SecondsSimpleDateFormat and iso8601SimpleDateFormat which underlie the behaviour.

The method that should presumably be called is iso8601SecondsDateParse. Or perhaps you can configure OpenNebula to return millis in its timestamps?

@gionn
Copy link
Author

gionn commented Mar 19, 2013

I've tryed patching OpenNebula to return milliseconds too, and my code works as expected.

However, the actual DateTime specification states:

In the formats described in this specification the whole number of seconds ·may· be followed by decimal seconds to an arbitrary level of precision

It would be nicer if jclouds could accept time with or without milliseconds.

Thanks!

@demobox
Copy link
Member

demobox commented Mar 20, 2013

I've tryed patching OpenNebula to return milliseconds too, and my code works as expected.

Glad to hear things work, at least. And given the specification you refer to, the correct patch is indeed probably not in OpenNebula, but in jclouds: replacing the call to iso8601DateParse (wherever it occurs the the case of the particular call you are making) with iso8601SecondsDateParse, or trying first one, then the other, or something similar.

@andrewgaul Thoughts on this one..?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants