Unparseable date: "2011 12 08T02:01:02+01:00"

Following code throws the exception when try to parse from the string (2011-12-08T02:01:02+01:00):

image.setLastUpdated(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz")
    .parse(imageElement.getAttribute("lastUpdate")))

I have also tried the following format:

image.setLastUpdated(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
    .parse(imageElement.getAttribute("lastUpdate")));

But I get the same exception:

java.text.ParseException: Unparseable date: "2011-12-08T02:01:02+01:00"
at java.text.DateFormat.parse(DateFormat.java:357)
at com.discavo.ImportManagerGiata.parseImageXML(ImportManagerGiata.java:204)
Jon Skeet
people
quotationmark

You need X as the specifier for the UTC offset as it's in ISO-8601 format, as per the SimpleDateFormat documentation.

new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX")

people

See more on this question at Stackoverflow