DateUtils { public static Date fromRfc3339DateString(String rfc3339FormattedDate) throws InvalidFormatException { SimpleDateFormat rfc3339DateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return rfc3339DateFormat.parse(rfc3339FormattedDate); } catch (ParseException e) { throw new InvalidFormatException( null, "Error parsing as date", rfc3339FormattedDate, 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 testFromRFC3339DateString() throws Exception { String input = "2018-01-15 12:16:11"; Date expectedOutput = rfc3339DateFormat.parse("2018-01-15 12:16:11"); assertEquals(expectedOutput, DateUtils.fromRfc3339DateString(input)); }