DateSegment implements Segment { @Override public String createToken(final String prefix, final Timestamp timestamp) { return formatter.format(timestamp); } DateSegment(final String format); @Override String getStaticText(); @Override boolean validateToken(final String token); @Override String createToken(final String prefix, final Timestamp timestamp);  }
@Test public void createToken() { DateSegment segment = new DateSegment("yyyy-MM-dd"); Instant instant = LocalDate.of(1985, 6, 3).atStartOfDay(ZoneOffset.systemDefault()).toInstant(); Timestamp timestamp = mock(Timestamp.class); when(timestamp.toDate()).thenReturn(Date.from(instant)); when(timestamp.toInstant()).thenReturn(instant); assertThat(segment.createToken(null, timestamp)).isEqualTo("1985-06-03"); }