DateSegment implements Segment { @Override public boolean validateToken(final String token) { return formatter.isValid(token); } 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 validateValidToken() { DateSegment segment = new DateSegment("yyyy-MM-dd"); assertThat(segment.validateToken("1985-06-03")).isTrue(); }
@Test public void validateInvalidToken() { DateSegment segment = new DateSegment("yyyy-MM-dd"); assertThat(segment.validateToken("1985-XX-03")).isFalse(); }