Render a formatted date.
Format Date object in different ways.
The date tag will allow you to format a Date in a quick and easy way. You can specify a custom format (eg. "dd/MM/yyyy hh:mm"), you can generate easy readable notations (like "in 2 hours, 14 minutes"), or you can just fall back on a predefined format with key 'struts.date.format' in your properties file. If that key is not defined, it will finally fall back to the default DateFormat.MEDIUM formatting. Note: If the requested Date object isn't found on the stack, a blank will be returned.
Configurable attributes are :-i18n key | default |
struts.date.format.past | {0} ago |
struts.date.format.future | in {0} |
struts.date.format.seconds | an instant |
struts.date.format.minutes | {0,choice,1#one minute|1<{0} minutes} |
struts.date.format.hours | {0,choice,1#one hour|1<{0} hours}{1,choice,0#|1#, one minute|1<, {1} minutes} |
struts.date.format.days | {0,choice,1#one day|1<{0} days}{1,choice,0#|1#, one hour|1<, {1} hours} |
struts.date.format.years | {0,choice,1#one year|1<{0} years}{1,choice,0#|1#, one day|1<, {1} days} |
In this case the format attribute will be used.
Condition 3: With nice attribute as false and no format attribute is specifiedi18n key | default |
struts.date.format | if one is not found DateFormat.MEDIUM format will be used |
<a:date name="person.birthday" format="dd/MM/yyyy" /> <a:date name="person.birthday" format="%{getText('some.i18n.key')}" /> <a:date name="person.birthday" nice="true" /> <a:date name="person.birthday" />
Date
Name |
Required |
Default |
Type |
Description |
---|---|---|---|---|
format | false | Object/String | Date or DateTime format pattern | |
nice | false | false | Boolean | Whether to print out the date nicely |
name | true | String | The date value to format | |
id | false | Object/String | id for referencing element. For UI and form tags it will be used as HTML id attribute |