}
try {
dateFormat = new SimpleDateFormat(formatString);
} catch (PatternSyntaxException e) {
throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "' " +
". Found invalid date format", e);
}
try {
Calendar cal = Calendar.getInstance();
cal.setTime(dateFormat.parse(value));
if (cal.get(Calendar.DAY_OF_WEEK) == Weekday.valueOf(weekday).getConstantValue()) {
log.info("Successful weekday validation matcher - All values OK");
} else {
throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'" +
". Received invalid week day '" + value + "', expected date to be a '" + weekday + "'");
}
} catch (ParseException e) {
throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'" +
". Received invalid date format for value '" + value + "', expected date format is '" + formatString + "'", e);
}
}