Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
1 view
by (2.6k points)

I have the following date: 2011-08-12T20:17:46.384Z. What format is this? I'm trying to parse it with Java 1.4 via DateFormat.getDateInstance().parse(dateStr) and I'm getting

java.text.ParseException: Unparseable date: "2011-08-12T20:17:46.384Z"

I think I should be using SimpleDateFormat for parsing, but I have to know the format string first. All I have for that so far is yyyy-MM-dd, because I don't know what the T means in this string--something time zone-related? This date string is coming from the lcmis:downloadedOn tag shown on Files CMIS download history media type.

1 Answer

0 votes
by (46k points)

The T is just critical to depart the date from the time, and the Z indicates "zero-hours offset" likewise comprehended as "Zulu time" (UTC). If your strings perpetually have a "Z" you can apply:

SimpleDateFormat format = new SimpleDateFormat(

"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);

format.setTimeZone(TimeZone.getTimeZone("UTC"));

Or trying Joda Time, you can apply ISODateTimeFormat.dateTime().

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 29, 2019 in Java by Suresh (3.4k points)
0 votes
1 answer

Browse Categories

...