I’m trying to parse this String
2014-04-04T14:28:38+02:00
It should be ISO 8601 format. But i can’t parse it to a correct Date. I’ve tried the following:
String example = "2014-04-04T14:28:38+02:00" public final static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz") Date tempDate = df.parse(example)
But I get always the message “unparseable Date” I can not change the example because it’s a value from a webservice.
Could it be there is a probleme with “+02:00” instead of “+0200” ?
Thanks a lot
Advertisement
Answer
Starting from Java7, to handle +02:00, you can use the following format:
"yyyy-MM-dd'T'hh:mm:ssXXX"
This can be seen in the SimpleDateFormat documentation