Annotation Interface DateConversion
Defines a form field (whether on a Struts Action or model of ModelDriven Struts Action) should be parsed to a Date type and error message to display if this fails. By default, DD/MM/YYYY format is expected but this can be overridden or use user's locale by setting format to empty string. Also, defines a view helper field receives a formatted datetime value. This is the default converter for Date fields.
There are two modes of behaviour for conversion, depending on the type of form field.
Form field type | Mode | Description |
---|---|---|
String | Pair conversion | Converts string field value to Date field named by parsedFieldName |
Date | Auto conversion | Converts directly from request parameter |
By default, messages are added to the actionErrors list but this can be overridden by messageType
:
- ERROR
- Message added to Action level error messages. Default.
- FIELD
- Message added to field error messages.
- MESSAGE
- Message added to Action level info messages.
Other parameters
- format
- If not empty string, fixed date format, using SimpleDateFormat format. Defaults to dd/MM/yyyy. Set to empty string to use format according to locale.
- localeCountry
- If not empty string, country code for specific locale, as used in Locale. If set, localeLanguage must also be set. Ignored if format is not empty string. Set to empty string to use ActionContext's locale. Defaults to empty string.
- localeLanguage
- If not empty string, language code for specific locale, as used in Locale. If set, localeCountry must also be set. Ignored if format is not empty string. Set to empty string to use ActionContext's locale. Defaults to empty string.
- message
- If not empty string, text message to display. Used if
messageKey
is empty string or finds no message. - messageKey
- If not empty string, message key to retrieve from Action's TextProvider. Uses
message
if no key provided or no message found. - parsedFieldName
- If not empty string, name of field to contain parsed value. Defaults to 'parsed' plus capitalised field name, such as 'parsedLimit'. Only applies for pair conversion.
- style
- Date style of a locale's date format to used, same as DateFormat date style. Ignored if format is not empty string. Defaults to SHORT.
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescription
-
Element Details
-
format
String format- Default:
"dd/MM/yyyy"
-
localeCountry
String localeCountry- Default:
""
-
localeLanguage
String localeLanguage- Default:
""
-
message
String message- Default:
""
-
messageKey
String messageKey- Default:
""
-
messageType
Required.MessageType messageType- Default:
ERROR
-
style
DateConversion.Style style- Default:
SHORT
-
parsedFieldName
String parsedFieldName- Default:
""
-