### Question:
DateConverter { @TypeConverter public static Long toTimestamp(Date date) { return date == null ? null : date.getTime(); }  @TypeConverter static Date toDate(Long timestamp); @TypeConverter static Long toTimestamp(Date date);  }### Answer:
@Test public void testToTimestamp() { long testTimestamp1 = DateConverter.toTimestamp(dateZero); assertEquals(timestampZero, testTimestamp1); long testTimestamp2 = DateConverter.toTimestamp(datePresentation); assertEquals(timestampPresentation, testTimestamp2); boolean exception = false; try { long testTimestamp3 = DateConverter.toTimestamp(dateNull); } catch (NullPointerException e) { exception = true; } assertTrue(exception); }