@Test public void parseISOTimestamp_impossible() throws Exception { Date date = DateUtil.parseISOTimestamp("2013-02-30T33:00:00"); assertThat("Testing an impossible date", date, nullValue()); }
public static Date parseISOTimestamp(String timestampStr) { for (String iso8601Format : ISO_8601_FORMATS) { try { SimpleDateFormat dateFmt = new SimpleDateFormat(iso8601Format); dateFmt.setTimeZone(getTimeZone("UTC")); dateFmt.setLenient(false); return dateFmt.parse(timestampStr); } catch (Exception ex) { LOGGER.error("unable to parse date", ex); } } return null; }
DateUtil { public static Date parseISOTimestamp(String timestampStr) { for (String iso8601Format : ISO_8601_FORMATS) { try { SimpleDateFormat dateFmt = new SimpleDateFormat(iso8601Format); dateFmt.setTimeZone(getTimeZone("UTC")); dateFmt.setLenient(false); return dateFmt.parse(timestampStr); } catch (Exception ex) { LOGGER.error("unable to parse date", ex); } } return null; } }
DateUtil { public static Date parseISOTimestamp(String timestampStr) { for (String iso8601Format : ISO_8601_FORMATS) { try { SimpleDateFormat dateFmt = new SimpleDateFormat(iso8601Format); dateFmt.setTimeZone(getTimeZone("UTC")); dateFmt.setLenient(false); return dateFmt.parse(timestampStr); } catch (Exception ex) { LOGGER.error("unable to parse date", ex); } } return null; } private  DateUtil(); }
DateUtil { public static Date parseISOTimestamp(String timestampStr) { for (String iso8601Format : ISO_8601_FORMATS) { try { SimpleDateFormat dateFmt = new SimpleDateFormat(iso8601Format); dateFmt.setTimeZone(getTimeZone("UTC")); dateFmt.setLenient(false); return dateFmt.parse(timestampStr); } catch (Exception ex) { LOGGER.error("unable to parse date", ex); } } return null; } private  DateUtil(); static Date parseISOTimestamp(String timestampStr); static Calendar createCalendarMidnight(final Date date); static String getUTCTime(); }
DateUtil { public static Date parseISOTimestamp(String timestampStr) { for (String iso8601Format : ISO_8601_FORMATS) { try { SimpleDateFormat dateFmt = new SimpleDateFormat(iso8601Format); dateFmt.setTimeZone(getTimeZone("UTC")); dateFmt.setLenient(false); return dateFmt.parse(timestampStr); } catch (Exception ex) { LOGGER.error("unable to parse date", ex); } } return null; } private  DateUtil(); static Date parseISOTimestamp(String timestampStr); static Calendar createCalendarMidnight(final Date date); static String getUTCTime();  }