Parsing Dates in ISO 8601 Format
The following question asks about the format of a date string that includes a "T" and a "Z":
I have a date string in the format "2011-08-12T20:17:46.384Z". How can I parse this date in Java?
The "T" is a literal separator between the date and time, and the "Z" denotes "zero hour offset" or "Zulu time" (UTC).
To parse this date string using SimpleDateFormat, you can use the following format string:
SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); format.setTimeZone(TimeZone.getTimeZone("UTC"));
Alternatively, you can use Joda Time's ISODateTimeFormat.dateTime() to parse dates in this format.
The above is the detailed content of How to Parse ISO 8601 Dates (e.g., '2011-08-12T20:17:46.384Z') in Java?. For more information, please follow other related articles on the PHP Chinese website!