LegacyTimestampFormatter implements TimestampFormatter { @Override public boolean isValid(final String timestamp) { try { parse(timestamp); return true; } catch (ParseException ex) { return false; } } LegacyTimestampFormatter(final String pattern, final Locale locale); @Override boolean isValid(final String timestamp); @Override String format(final Timestamp timestamp);  }
@Test public void acceptValidFormattedTimestamp() { LegacyTimestampFormatter formatter = new LegacyTimestampFormatter("HH:mm:ss.SSS", Locale.US); assertThat(formatter.isValid("12:30:55.999")).isTrue(); }
@Test public void refuseInvalidFormattedTimestamp() { LegacyTimestampFormatter formatter = new LegacyTimestampFormatter("HH:mm:ss.SSS", Locale.US); assertThat(formatter.isValid("1985-06-03")).isFalse(); }