DatePatternValidationMatcher implements ValidationMatcher { public void validate(String fieldName, String value, List<String> controlParameters, TestContext context) throws ValidationException { String control = controlParameters.get(0); SimpleDateFormat dateFormat; try { dateFormat = new SimpleDateFormat(control); } catch (PatternSyntaxException e) { throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "' " + ". Found invalid date format", e); } try { dateFormat.parse(value); } catch (ParseException e) { throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'" + ". Received invalid date format for value '" + value + "', expected date format is '" + control + "'", e); } }  void validate(String fieldName, String value, List<String> controlParameters, TestContext context);  }
@Test public void testValidateSuccess() { matcher.validate("field", "2011-10-10", Arrays.asList("yyyy-MM-dd"), context); matcher.validate("field", "10.10.2011", Arrays.asList("dd.MM.yyyy"), context); matcher.validate("field", "2011-01-01T01:02:03", Arrays.asList("yyyy-MM-dd'T'HH:mm:ss"), context); }