package com.ksoichiro.task.util;

import org.junit.Test;

import java.util.Date;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class DateUtilsTests {
    @Test
    public void parse() {
        String expr = "2016-12-11 10:01:30";
        String pattern = "uuuu-MM-dd HH:mm:ss";
        Date d = DateUtils.toDateFromString(expr, pattern);
        assertThat(DateUtils.toStringFromDate(d, pattern), is(expr));
    }

    @Test
    public void parseWithoutPattern() {
        assertThat(DateUtils.toStringFromDate(DateUtils.toDateFromString("2016-12-11 10:01:02"), "uuuu-MM-dd HH:mm:ss"), is("2016-12-11 10:01:02"));
        assertThat(DateUtils.toStringFromDate(DateUtils.toDateFromString("2016-12-11"), "uuuu-MM-dd HH:mm:ss"), is("2016-12-11 00:00:00"));
    }
}

@@ -189,16 +189,344 @@
 Tests %7B%0A
+    @Test%0A    public void truncateTime() %7B%0A        String expr = %222016-12-11 10:01:30%22;%0A        String pattern = %22uuuu-MM-dd HH:mm:ss%22;%0A        Date d = DateUtils.toDateFromString(expr, pattern);%0A        assertThat(DateUtils.toStringFromDate(DateUtils.truncateTime(d), %22uuuu-MM-dd HH:mm:ss%22), is(%222016-12-11 00:00:00%22));%0A    %7D%0A%0A
     @Tes

Add test for DateUtils