Groovy Date Analysis - X is an illegal character symbol

I have the following date string: 2011-09-06T22:02:57-04:00 . The problem is the time zone, -04: 00 . Java7 docs say that I can use XXX to magically match this timezone line: 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 does not yet use JDK7. The z symbol does not work because it is not GMT-07:00 , only -07:00 . What is the easiest way to analyze this time zone?

-tjw

+8
java date groovy
source share
2 answers

The simplest answer I can come up with is to simply use "Z". The problem here is that -04: 00 is not recognized by the parser. So, why not just run the regular expression before trying to convert it, looking for the final: and deleting it.

+1
source share

you can use DatatypeConverter.parseDateTime (jaxb support) to parse this date format.

+1
source share

All Articles