Annotation Type 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 using same name as field. |
| MESSAGE | Message added to Action level info messages. |
| WARNING | Message added to Action level warning messages. |
Other parameters
| actionContextTimeZone | Name of ActionContext value of TimeZone instance for time formatting. Resorts to system time zone if no value found or name is empty string. Ignored if timezone format is not empty string (which defaults to "UTC"). Defaults to empty string. |
| 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 be used, same as DateFormat date style. Ignored if format is not empty string. Defaults to SHORT. |
| timeStyle | Time style of a locale's time format to be used, same as DateFormat date style, unless set to NONE. Ignored if format is not empty string. Defaults to NONE. |
| timezone | If not empty string, name of time zone recognised by TimeZone.getTimeZone(). Set to empty string to default to time zone found by actionContextTimeZone. Defaults to "UTC". |
When applied to a view helper field, StrutsMiscellaneousLibrary#updateDisplay
formats from a source record field with the same name but only certain combinations are recognised.
| Display field type | Record field type | Notes |
|---|---|---|
| String | Date | |
| String array | Date array | |
| String array | Date collection | |
| String collection | Date array | |
| String collection | Date collection |
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescription
-
Element Details
-
actionContextTimeZone
String actionContextTimeZone- Default:
""
-
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
-
parsedFieldName
String parsedFieldName- Default:
""
-
style
DateConversion.Style style- Default:
SHORT
-
timeStyle
DateConversion.TimeStyle timeStyle- Default:
NONE
-
timezone
String timezone- Default:
"UTC"
-