### Question:
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; }### Answer:
@Test public final void shouldParseDateFromNullAsNull() { final Object input = null; final Date result = DateUtils.parseDate(input); assertNull(result); }
@Test public final void shouldParseDateFromEmptyStringAsNull() { final Object input = ""; final Date result = DateUtils.parseDate(input); assertNull(result); }
@Test public final void shouldParseDateFromBlankStringAsNull() { final Object input = " "; final Date result = DateUtils.parseDate(input); assertNull(result); }
@Test public final void shouldParseDateFromDateString() { final Object input = "2013-01-01"; final Date result = DateUtils.parseDate(input); assertDateEquals(new DateTime(2013, 1, 1, 0, 0, 0, 0), result); }
@Test public final void shouldParseDateFromDateTimeString() { final Object input = "2013-01-01 12:30:45"; final Date result = DateUtils.parseDate(input); assertDateEquals(new DateTime(2013, 1, 1, 12, 30, 45, 0), result); }
@Test public final void shouldParseDateFromLongTimestamp() { final DateTime dateTime = new DateTime(2013, 1, 1, 12, 30, 45, 0); final Object input = dateTime.getMillis(); final Date result = DateUtils.parseDate(input); assertDateEquals(dateTime, result); }
@Test public final void shouldParseDateFromBigIntegerTimestamp() { final DateTime dateTime = new DateTime(2013, 1, 1, 12, 30, 45, 0); final Object input = BigInteger.valueOf(dateTime.getMillis()); final Date result = DateUtils.parseDate(input); assertDateEquals(dateTime, result); }
@Test public final void shouldParseDateFromDate() { final DateTime dateTime = new DateTime(2013, 1, 1, 12, 30, 45, 0); final Object input = dateTime.toDate(); final Date result = DateUtils.parseDate(input); assertDateEquals(dateTime, result); }
@Test public final void shouldThrowExceptionIfInputTypeIsUnsupported() { final Object input = new Object(); try { DateUtils.parseDate(input); Assert.fail(); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail(); } }
@Test public final void shouldThrowExceptionIfInputStringHasIncorrectFormat() { final Object input = "123 or some text"; try { DateUtils.parseDate(input); Assert.fail(); } catch (IllegalArgumentException iae) { } catch (Exception e) { Assert.fail(); } }