DateConverter implements Converter<Date, Long> { @NonNull @Override public Long toSupported(@Nullable Date converted) { if (converted == null) { return DEFAULT_TIMESTAMP; } return converted.getTime(); }  @NonNull @Override Date toConverted(@Nullable Long supported); @NonNull @Override Long toSupported(@Nullable Date converted);  }
@Test public void toSupportedShouldReturnTimestamp() throws Exception { final Calendar calendar = Calendar.getInstance(); calendar.set(2016, Calendar.NOVEMBER, 28, 20, 0, 0); final Long actual = underTest.toSupported(calendar.getTime()); assertThat(actual) .isEqualTo(calendar.getTimeInMillis()); }
@Test public void toSupportedShouldReturnZeroWhenDateIsNull() throws Exception { final Long actual = underTest.toSupported(null); assertThat(actual) .isZero(); }