Java 8 Date and Time API - parse yyyy-MM-dd'T'HH:mm:ss.SSSZ

I am not sure this is your expected answer.

Method 1

Parse using Instant

Instant.parse("2015-06-28T10:13:14.743Z");

Method 2

The given input format is equivalent to ISO_DATE_TIME format after removing 'Z' from the given pattern yyyy-MM-dd'T'HH:mm:ss.SSSZ

Then we can parse it using ISO_DATE_TIME

 text = "2015-06-28T10:13:14.743"
 LocalDateTime.parse(text,DateTimeFormatter.ISO_DATE_TIME)

You are correct in that this does not appear to match any of the default formats, so you would need to build your format with a java.time.format.DateTimeFormatterBuilder.


You should never be bothered by those annoying date-format.

There has an new library dateparser.

It can recognize any String automatically, and parse it into Date, Calendar, LocalDateTime, OffsetDateTime correctly.

With it, you don't have to prepare any appropriate patterns like yyyy-MM-dd'T'HH:mm:ss.SSSZ or yyyy-MM-dd'T'HH:mm:ss.SSSZZ:

Date date = DateParserUtils.parseDate("2015-04-29T10:15:00.500+0000");
Calendar calendar = DateParserUtils.parseCalendar("2015-04-29T10:15:00.500Z");
LocalDateTime dateTime = DateParserUtils.parseDateTime("2015-04-29 10:15:00.500 +00:00");

All works fine, please enjoy it.