javaandroidparsingdatesimpledateformat

Issue with parsing Date string


I'm trying to parse the following string to a Date object:

2013-12-26T01:00:56.664Z

Using this SimpleDateFormat:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

But I'm getting a:

 java.text.ParseException: Unparseable date: "2013-12-26T01:00:56.664Z" (at offset 19)

What am I doing wrong, How I should handle the T and the Z letters in the date?


Solution

  • The real isssue with the date is not T & Z but the milliseconds.

    "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" This must be the format that is to be used becaue there are milli seconds as well in the input date.