DateTimes { public static LocalDateTime tryParseLocalDateTime(CharSequence text) { if(null == text || text.length() == 0){ return null; } LocalDateTime dt = tryParseLocalDateTime(text, DateTimeFormatter.ISO_LOCAL_DATE_TIME); if(dt == null) { String s = text.toString(); Date d = Dates.tryParse(s,DateFormats.DATETIME_FORMATTER); if(null != d){ return toLocalDateTime(d); } d = Dates.tryParse(s,DateFormats.DATE_FORMATTER); if(null != d){ return toLocalDateTime(d); } } return dt; } protected  DateTimes(); static LocalDate tryParseLocalDate(CharSequence text); static LocalDate tryParseLocalDate(CharSequence text,DateTimeFormatter formatter); static LocalTime tryParseLocalTime(CharSequence text); static LocalTime tryParseLocalTime(CharSequence text,DateTimeFormatter formatter); static LocalDateTime tryParseLocalDateTime(CharSequence text); static LocalDateTime tryParseLocalDateTime(CharSequence text,DateTimeFormatter formatter); static Instant tryParseInstant(CharSequence text); static LocalDate toLocalDate(Date d); static LocalDate toLocalDate(Instant i); static LocalTime toLocalTime(Date d); static LocalTime toLocalTime(Instant i); static LocalDateTime toLocalDateTime(Date d); static LocalDateTime toLocalDateTime(Instant i);  }
@Test public void testParseLocalDateTimeWithDefaultFormat() { LocalDateTime dt = LocalDateTime.of(2014, 11, 1, 10, 01, 01); assertEquals(dt,DateTimes.tryParseLocalDateTime("2014-11-01T10:01:01")); assertEquals(dt,DateTimes.tryParseLocalDateTime("2014-11-01 10:01:01")); }