I have the following date string: 2011-09-06T22:02:57-04:00
. The problem is the timezone, -04:00. The Java7 docs say I can use XXX
to magically match this timezone string: http://download.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
The problem is that Groovy does not support the X
character, presumably because it's not using JDK7 yet. The z
character doesn't work because it isn't GMT-07:00
, only -07:00
What is the easiest way to parse this timezone?
-tjw
The simplest answer I can think of, is just to use 'Z'. The issue here is that -04:00 isn't recognised by the parser. So why not just run a regex prior to trying to convert it, looking for the final : and removing it.
you can use DatatypeConverter.parseDateTime (jaxb support) to parse this date format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With