### Question:
DateUtil { public static Date truncateToSeconds(Date date) { Instant instant = date.toInstant().truncatedTo(ChronoUnit.SECONDS); return Date.from(instant); } private  DateUtil(); static Date truncateToSeconds(Date date);  }### Answer:
@Test public void truncateToSeconds_shouldDropMilliseconds() { Date withMilliseconds = new Date(123L); Date withoutMilliseconds = new Date(0L); assertThat(DateUtil.truncateToSeconds(withMilliseconds), is(withoutMilliseconds)); assertThat(DateUtil.truncateToSeconds(withoutMilliseconds), is(withoutMilliseconds)); }