DateConverter { public static long toTimestamp(final Date date) { return date != null ? date.getTime() : EMPTY_TIMESTAMP; } private  DateConverter(); static Long[][] encode(final Collection<Date> dates); static Long encode(final Date date); static Date decode(final long timestamp); static long toTimestamp(final Date date); static Date fromTimestamp(final long timestamp);  }
@Test public void testToTimestamp() { final int expectedTimestamp = 123; final long timestamp = DateConverter.toTimestamp(new Date(expectedTimestamp)); assertEquals(expectedTimestamp, timestamp); assertEquals(-1, DateConverter.toTimestamp(null)); }