Requires that the value be a timestamp 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.
Javadoc Ref :
@IsTimestamp
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 a date |
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 java.util.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. |
@IsTimestamp
private Date timeField;
@IsTimestamp("yyyy.MM.dd HH-mm-ss")
private Date timeWithPattern;
@IsTimestamp(
value="yyyy.MM.dd HH-mm-ss",
defaultValue="2007.10.29 18-49-50")
private Date timeWithDefault;
@IsTimestamp(
value="yyyy.MM.dd HH-mm-ss",
defaultValue="2007.10.29 18-49-50")
private String string;