views:

4477

answers:

2

I have dates in the format 2008-12-23T00:00:00Z. This look a lot like a ISO 8601 format with a Zulu (UTC) timezone. I though the following code would parse it (using commons-lang) :

String pattern = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern();
Date d = DateUtils.parseDate(dateToParse, new String[] { pattern });

If I take the same pattern (yyyy-MM-dd'T'HH:mm:ssZZ) but remove the timezone, it works.

Do you know how I can recognize the Zulu timezone ? I have access only to Java 1.4 and Jakarta commons-lang. No Joda Time for me yet ...

+2  A: 

Looks like a bug in commons-lang's FastDateFormat. Tell them about it, and you should get a fix eventually. Till then you could try to preprocess the dates and replace 'Z' with '+00'

Michael Borgwardt
Ok, I'll try that. I wont be able to upgrade to a new version of the commons-lang before a few years ;-) but it might help somebody else ...
Guillaume
+10  A: 
Argelbargel
+1... I always have to look this crap up when I'm not using JodaTime
iandisme