Annotation Interface DateConversion


@Documented @Inherited @Target(FIELD) @Retention(RUNTIME) public @interface DateConversion

Defines a String form field (whether on a Struts Action or model of ModelDriven Struts Action) should be parsed to a recipient field of 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.

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'.
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.
  • 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

      Default:
      ERROR
    • style

      Default:
      SHORT
    • parsedFieldName

      String parsedFieldName
      Default:
      ""