I have a String of a date and time like this: 2011-04-15T20:08:18Z
. I don\'t know much about date/time formats, but I think, and correct me if I\'m wrong, that\
The Java 7 version of SimpleDateFormat supports ISO-8601 time zones using the uppercase letter X
.
String string = "2011-04-15T20:08:18Z";
DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
Date date = iso8601.parse(string);
If you're stuck with Java 6 or earlier, the answer recommending JodaTime is a safe bet.