Thanks to Daylight Saving Time, you might run into this error while using the excellent Joda-Time library:
java.lang.IllegalArgumentException: Cannot parse "2014-03-09T02:01:47Z": Illegal instant due to time zone offset transition (America/Los_Angeles)
I'm getting this pulling UTC timestamps out of Solr. My app's input and output will always be UTC. The offending code:
I'm getting this pulling UTC timestamps out of Solr. My app's input and output will always be UTC. The offending code:
Most answers on the web related to this error correctly indicate you should probably use LocalDateTime. But what if you want to remain UTC? Just tell the formatter to not revert to the local time zone. This makes the rest of the app safer as well because it's not handling time values which were translated from UTC to local.
No comments:
Post a Comment