I had code that parses date as follows:
String ALT_DATE_TIME_FORMAT = \"yyyy-MM-dd\'T\'HH:mm:ss.SSSZ\";
SimpleDateFormat sdf = new SimpleDateFormat(
SimpleDateFormat only accepts -0800
or GMT-08:00
as the timezone.
It seems the ISO 8601 format can not be parsed with SimpleDateFormat
. Maybe you should have a look at Apache Commons Lang's FastDateFormat. It is compatible with SimpleDateFormat
but accepts the ZZ
pattern for the timezone that should parse the timezone format you need. DateFormatUtils contains some example constants that look like the pattern you need, just without the milliseconds (for example ISO_DATETIME_TIME_ZONE_FORMAT).