DateUtils { public static Date fromISODateString(String isoFormattedDate) throws com.fasterxml.jackson.databind.exc.InvalidFormatException { SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); isoDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); try { return isoDateFormat.parse(isoFormattedDate); } catch (ParseException e) { throw new InvalidFormatException(null, "Error parsing as date", isoFormattedDate, Date.class); } } private  DateUtils(); static Date fromMillisUtc(long millisecondsFromEpoch); static String toUTCString(Date date); static Date fromISODateString(String isoFormattedDate); static Date fromISO8601DateString(String iso8601FormattedDate); static Date fromRfc1123DateString(String rfc1123FormattedDate, Locale locale); static Date fromRfc3339DateString(String rfc3339FormattedDate); static long toUnixTime(long javaTime); static long toUnixTime(Date time); static Long toUnixTimeNullSafe(Date time); static Long toMillisNullSafe(Date time); static Date fromUnixTime(long unix);  }
@Test public void testFromISODateString() throws Exception { String input = "2016-06-10T12:16:11.717Z"; Date expectedOutput = isoDateFormat.parse("2016-06-10T12:16:11.717"); assertEquals(expectedOutput, DateUtils.fromISODateString(input)); }
@Test(expected = InvalidFormatException.class) public void testFromISODateStringWrongTimezone() throws Exception { String input = "2016-06-10T12:16:11.717"; Date expectedOutput = isoDateFormat.parse("2016-06-10T12:16:11.717"); assertEquals(expectedOutput, DateUtils.fromISODateString(input)); }