Requires that the value be a date value. If it is not, it will attempt to perform a conversion according either using a provided pattern, or using the locale-dependant default pattern. Usually date conversions are performed automatically. You should use this annotation only if you want to specify a custom date pattern, and wish to avoid the number-to-date conversions
Javadoc Ref :
@IsDate
Input Types 1 |
Object |
Output Types |
java.util.Date or String |
1Automatic conversion will take place if the provided input does not match any of the input classes, as described in the conversions part of the manual.
value |
Pattern to use when parsing the data, if it is not natively dat |
defaultValue |
If set to something different than the default (the empty string), specifies a default value that is used whenever a null value is received. The default value is parsed to a Date. |
message |
Literal message to use if validation fails. |
errorCode |
Error code to use if validation fails. |
messageKey |
Message key to use if validation fails. |
@IsDate
private Date dateField;
@IsDate("dd/MM/yyyy")
private Date dateWithPattern;
@IsDate(value="dd/MM/yyyy",defaultValue="14/01/2007")
private Date dateWithDefault;