@Test public void shouldAcceptABunchOfStrings() { final Locale l = Locale.getDefault(); try { Locale.setDefault(Locale.US); for (final String s : new String[] { "2020-01-01", "01/01/2020", "01/01/2020", "2020-01-01T15:00", "2020-01-01 15:00:00Z", "01/01/2020 15:00", }) { final ComparisonResult comparisonResult = placeholderHandler.evaluate(s); assertThat(comparisonResult, equalTo(ComparisonResult.EQUAL)); } } finally { Locale.setDefault(l); } }
@Override public ComparisonResult evaluate(final String testText, final String... args) { if (args != null && args.length == 1) { return canParse(new SimpleDateFormat(args[0]), testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } return canParse(testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; }
IsDateTimePlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(final String testText, final String... args) { if (args != null && args.length == 1) { return canParse(new SimpleDateFormat(args[0]), testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } return canParse(testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } }
IsDateTimePlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(final String testText, final String... args) { if (args != null && args.length == 1) { return canParse(new SimpleDateFormat(args[0]), testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } return canParse(testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; }  }
IsDateTimePlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(final String testText, final String... args) { if (args != null && args.length == 1) { return canParse(new SimpleDateFormat(args[0]), testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } return canParse(testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; }  @Override String getKeyword(); @Override ComparisonResult evaluate(final String testText, final String... args); }
IsDateTimePlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(final String testText, final String... args) { if (args != null && args.length == 1) { return canParse(new SimpleDateFormat(args[0]), testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; } return canParse(testText) ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; }  @Override String getKeyword(); @Override ComparisonResult evaluate(final String testText, final String... args);  }