rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

DateTime's parseRfc3339 does not respect optional zone minute delimitor ":" #260

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.15.0-rc)?
1.17.0-rc

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Android 4.0

Describe the problem.
When parsing the date:
2014-04-28T13:19:46.748-0500
DateTime throws the exception:
java.lang.StringIndexOutOfBoundsException: String index out of range: 29
Since it searches the zone minutes assuming there is a delimiter character 
between 05 and 00, thus assuming the string is 1 character longer than it is.

How would you expect it to be fixed?
To respect RFC 3339, this implementation should adhere to:
   time-numoffset    = ("+" / "-") time-hour [[":"] time-minute]
   time-zone         = "Z" / time-numoffset
Which means the time-minute needs to become both optional and if present 
optionally delimited by a :.

Original issue reported on code.google.com by lhunath@lyndir.com on 28 Apr 2014 at 6:23

GoogleCodeExporter commented 9 years ago
RFC 3339 does not define it as you described. Instead it has in Section 5.6:

time-numoffset  = ("+" / "-") time-hour ":" time-minute
time-offset     = "Z" / time-numoffset

The definition you provided is in Appendix A which describes ISO 8601. From my 
(brief) reading, it seems RFC 3339 is supposed to be a subset ("profile") of 
ISO 8601.

Original comment by ejona@google.com on 28 Apr 2014 at 7:37

GoogleCodeExporter commented 9 years ago
Hmm.  That's fair.  Since we're parsing server responses and there are way too 
many time format standards and interpretations, could we get some way of 
providing a custom way of parsing in a typed time value?  If only somethig 
like, "when converting a string to a type and we have no hardcoded way of doing 
it, see if the type has a Type(String) constructor?

Original comment by lhunath@lyndir.com on 28 Apr 2014 at 8:26

GoogleCodeExporter commented 9 years ago

Original comment by wonder...@google.com on 30 Dec 2014 at 10:43