I am almost finished with a page that builds out it fields dynamically and sets validation of data types using regular expressions, but ran into an issue on Friday when I started tying the fields to actual data types instead of just Strings. The problem is with values tied to Dates (java.util.Date) !!
While testing out the page and validations I am populating the date field with a date such as 12/12/2012. When it reaches the validate method it is being shown as Tue Dec 11 19:00:00 EST 2012. The date being shown is always a day earlier @ 19:00:00 and in a completely different format.
What can I do to get the date sent in the format I specified ?
...also...
Any ideas on why the date value is not correct as well ?
Building the date field on the page:
<h:inputText id="inputField2" tabindex="#{field.fieldDefinition.fieldOrder}" value="#{field.val}" validator="#{field.fieldDefinition.validate}" validatorMessage="#{field.fieldDefinition.validationMessage}">
<f:convertDateTime pattern="MM/dd/yyyy" />
</h:inputText>
The Validation method being called:
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
if (getDataType() != null && getDataType().getValidationExpression() != "") {
regexValidator = new RegexValidator();
regexValidator.setPattern(getDataType().getValidationExpression());
regexValidator.validate(context, component, value);
}
}
As always...thanks for the help.
Regards,
Mike