### Question:
DateUtil { public static java.sql.Date columnToDate(Object column,SimpleDateFormat customTimeFormat) { if(column == null) { return null; } else if(column instanceof String) { if (((String) column).length() == 0){ return null; } Date date = stringToDate((String)column, customTimeFormat); if (null == date) { return null; } return new java.sql.Date(date.getTime()); } else if (column instanceof Integer) { Integer rawData = (Integer) column; return new java.sql.Date(getMillSecond(rawData.toString())); } else if (column instanceof Long) { Long rawData = (Long) column; return new java.sql.Date(getMillSecond(rawData.toString())); } else if (column instanceof java.sql.Date) { return (java.sql.Date) column; } else if(column instanceof Timestamp) { Timestamp ts = (Timestamp) column; return new java.sql.Date(ts.getTime()); } else if(column instanceof Date) { Date d = (Date)column; return new java.sql.Date(d.getTime()); } throw new IllegalArgumentException("Can't convert " + column.getClass().getName() + " to Date"); } private  DateUtil(); static java.sql.Date columnToDate(Object column,SimpleDateFormat customTimeFormat); static java.sql.Timestamp columnToTimestamp(Object column,SimpleDateFormat customTimeFormat); static long getMillSecond(String data); static Date stringToDate(String strDate,SimpleDateFormat customTimeFormat); static String dateToString(Date date); static String timestampToString(Date date); static String dateToYearString(Date date); static SimpleDateFormat getDateTimeFormatter(); static SimpleDateFormat getDateFormatter(); static SimpleDateFormat getTimeFormatter(); static SimpleDateFormat getYearFormatter(); static SimpleDateFormat buildDateFormatter(String timeFormat); final static String DATE_REGEX; final static String TIMESTAMP_REGEX; final static String DATETIME_REGEX; final static int LENGTH_SECOND; final static int LENGTH_MILLISECOND; final static int LENGTH_MICROSECOND; final static int LENGTH_NANOSECOND; static ThreadLocal<Map<String,SimpleDateFormat>> datetimeFormatter; }### Answer:
@Test public void testColumnToDate() { Date result = DateUtil.columnToDate(null, null); Assert.assertNull(result); result = DateUtil.columnToDate("", null); Assert.assertNull(result); result = DateUtil.columnToDate("2020-03-18 10:56:00", null); Assert.assertEquals(result, new Date(1584500160000L)); result = DateUtil.columnToDate(1584500160, null); Assert.assertEquals(result, new Date(1584500160000L)); result = DateUtil.columnToDate(1584500160000L, null); Assert.assertEquals(result, new Date(1584500160000L)); result = DateUtil.columnToDate(new Date(1584500160000L), null); Assert.assertEquals(result, new Date(1584500160000L)); result = DateUtil.columnToDate(new Timestamp(1584500160000L), null); Assert.assertEquals(result, new Date(1584500160000L)); result = DateUtil.columnToDate(new java.util.Date(1584500160000L), null); Assert.assertEquals(result, new Date(1584500160000L)); try { DateUtil.columnToDate(true, null); } catch (Exception e) { Assert.assertTrue(e instanceof IllegalArgumentException); } }