@Test public final void shouldParseDateFromNullAsNull() { final Object input = null; final Date result = DateUtils.parseDate(input); assertNull(result); }
public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { DateUtils.L_DATE_TIME_FORMAT, DateUtils.L_DATE_FORMAT }); } catch (ParseException e) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value), e); } } } else if (value instanceof Date) { date = new Date(((Date) value).getTime()); } else if (value instanceof Number) { date = new Date(((Number) value).longValue()); } else if (value != null) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value)); } return date; }
DateUtils { public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { DateUtils.L_DATE_TIME_FORMAT, DateUtils.L_DATE_FORMAT }); } catch (ParseException e) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value), e); } } } else if (value instanceof Date) { date = new Date(((Date) value).getTime()); } else if (value instanceof Number) { date = new Date(((Number) value).longValue()); } else if (value != null) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value)); } return date; } }
DateUtils { public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { DateUtils.L_DATE_TIME_FORMAT, DateUtils.L_DATE_FORMAT }); } catch (ParseException e) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value), e); } } } else if (value instanceof Date) { date = new Date(((Date) value).getTime()); } else if (value instanceof Number) { date = new Date(((Number) value).longValue()); } else if (value != null) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value)); } return date; } private  DateUtils(); }
DateUtils { public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { DateUtils.L_DATE_TIME_FORMAT, DateUtils.L_DATE_FORMAT }); } catch (ParseException e) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value), e); } } } else if (value instanceof Date) { date = new Date(((Date) value).getTime()); } else if (value instanceof Number) { date = new Date(((Number) value).longValue()); } else if (value != null) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value)); } return date; } private  DateUtils(); static Date parseAndComplete(final String dateExpression, final boolean upComplete); static String toDateTimeString(final Date date); static String toDateString(final Date date); static Date parseDate(final Object value); static Either<? extends Exception, Optional<DateTime>> tryParse(final Object value); static Date copy(final Date date); }
DateUtils { public static Date parseDate(final Object value) { Date date = null; if (value instanceof String) { if (StringUtils.isNotBlank((String) value)) { try { date = org.apache.commons.lang3.time.DateUtils.parseDateStrictly((String) value, new String[] { DateUtils.L_DATE_TIME_FORMAT, DateUtils.L_DATE_FORMAT }); } catch (ParseException e) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value), e); } } } else if (value instanceof Date) { date = new Date(((Date) value).getTime()); } else if (value instanceof Number) { date = new Date(((Number) value).longValue()); } else if (value != null) { throw new IllegalArgumentException(String.format(PARSE_EXCEPTION_MSG, value)); } return date; } private  DateUtils(); static Date parseAndComplete(final String dateExpression, final boolean upComplete); static String toDateTimeString(final Date date); static String toDateString(final Date date); static Date parseDate(final Object value); static Either<? extends Exception, Optional<DateTime>> tryParse(final Object value); static Date copy(final Date date); static final String L_DATE_FORMAT; static final String L_DATE_TIME_FORMAT; static final String L_REPORT_DATE_TIME_FORMAT; }