DateUtils { public static Date parseDate(DataColumn dateColumn, Object date) throws Exception { DateIntervalType type = DateIntervalType.getByName(dateColumn.getIntervalType()); GroupStrategy strategy = dateColumn.getColumnGroup().getStrategy(); return parseDate(type, strategy, date); }  static Date parseDate(DataColumn dateColumn, Object date); static Date parseDate(DateIntervalType type, GroupStrategy strategy, Object date); static String ensureTwoDigits(String date, DateIntervalType intervalType); static String ensureTwoDigits(String date, String symbolStart, String symbolEnd); static final SimpleDateFormat FORMATTER_YEAR; static final SimpleDateFormat FORMATTER_MONTH; static final SimpleDateFormat FORMATTER_DAY; static final SimpleDateFormat FORMATTER_HOUR; static final SimpleDateFormat FORMATTER_MINUTE; static final SimpleDateFormat FORMATTER_SECOND; }
@Test public void testParseSecond() throws Exception { Date result = DateUtils.parseDate(DateIntervalType.SECOND, GroupStrategy.DYNAMIC, "2015-1-23 3:0:1"); assertThat(df.format(result)).isEqualTo("2015-01-23 03:00:01"); }
@Test public void testParseMinute() throws Exception { Date result = DateUtils.parseDate(DateIntervalType.MINUTE, GroupStrategy.DYNAMIC, "2015-1-23 3:1"); assertThat(df.format(result)).isEqualTo("2015-01-23 03:01:00"); }
@Test public void testParseHour() throws Exception { Date result = DateUtils.parseDate(DateIntervalType.HOUR, GroupStrategy.DYNAMIC, "2015-1-23 3"); assertThat(df.format(result)).isEqualTo("2015-01-23 03:00:00"); }
@Test public void testParseDay() throws Exception { Date result = DateUtils.parseDate(DateIntervalType.DAY, GroupStrategy.DYNAMIC, "2015-1-23"); assertThat(df.format(result)).isEqualTo("2015-01-23 00:00:00"); }
@Test public void testParseMonth() throws Exception { Date result = DateUtils.parseDate(DateIntervalType.MONTH, GroupStrategy.DYNAMIC, "2015-1"); assertThat(df.format(result)).isEqualTo("2015-01-01 00:00:00"); }