blob: 2e2e9c7f69e2bdf8aa9b87209f64afeb2a7e736f [file] [log] [blame]
<html>
<head>
<title>&lt;a2:date /&gt;</title>
</head>
<body>
<h1>Tag Name: &lt;a2:date /&gt;</h1>
<h2>Description</h2>
<p>
Render a formatted date.
</p>
<p>
<!-- START SNIPPET: javadoc --> Format Date object in different ways. <p> The date tag will allow you to format a Date in a quick and easy way. You can specify a <b>custom format</b> (eg. "dd/MM/yyyy hh:mm"), you can generate <b>easy readable notations</b> (like "in 2 hours, 14 minutes"), or you can just fall back on a <b>predefined format</b> 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. <b>Note</b>: If the requested Date object isn't found on the stack, a blank will be returned. </p> Configurable attributes are :- <ul> <li>name</li> <li>nice</li> <li>format</li> </ul> <p/> Following how the date component will work, depending on the value of nice attribute (which by default is false) and the format attribute. <p/> <b><u>Condition 1: With nice attribute as true</u></b> <table border="1"> <tr> <td>i18n key</td> <td>default</td> </tr> <tr> <td>struts.date.format.past</td> <td>{0} ago</td> </tr> <tr> <td>struts.date.format.future</td> <td>in {0}</td> </tr> <tr> <td>struts.date.format.seconds</td> <td>an instant</td> </tr> <tr> <td>struts.date.format.minutes</td> <td>{0,choice,1#one minute|1<{0} minutes}</td> </tr> <tr> <td>struts.date.format.hours</td> <td>{0,choice,1#one hour|1<{0} hours}{1,choice,0#|1#, one minute|1<, {1} minutes}</td> </tr> <tr> <td>struts.date.format.days</td> <td>{0,choice,1#one day|1<{0} days}{1,choice,0#|1#, one hour|1<, {1} hours}</td> </tr> <tr> <td>struts.date.format.years</td> <td>{0,choice,1#one year|1<{0} years}{1,choice,0#|1#, one day|1<, {1} days}</td> </tr> </table> <p/> <b><u>Condition 2: With nice attribute as false and format attribute is specified eg. dd/MM/yyyyy </u></b> <p>In this case the format attribute will be used.</p> <p/> <b><u>Condition 3: With nice attribute as false and no format attribute is specified </u></b> <table border="1"> <tr> <td>i18n key</td> <td>default</td> </tr> <tr> <td>struts.date.format</td> <td>if one is not found DateFormat.MEDIUM format will be used</td> </tr> </table> <!-- END SNIPPET: javadoc --> <p/> <b>Examples</b> <pre> <!-- START SNIPPET: example --> &lt;a:date name="person.birthday" format="dd/MM/yyyy" /&gt; &lt;a:date name="person.birthday" format="%{getText('some.i18n.key')}" /&gt; &lt;a:date name="person.birthday" nice="true" /&gt; &lt;a:date name="person.birthday" /&gt; <!-- END SNIPPET: example --> </pre> <code>Date</code>
</p>
<h2>Attributes</h2>
<p>
<!-- START SNIPPET: tagattributes -->
<table width="100%">
<tr>
<th align="left" valign="top"><h4>Name</h4></th>
<th align="left" valign="top"><h4>Required</h4></th>
<th align="left" valign="top"><h4>Default</h4></th>
<th align="left" valign="top"><h4>Type</h4></th>
<th align="left" valign="top"><h4>Description</h4></th>
</tr>
<tr>
<!-- Attribute name -->
<td align="left" valign="top">format</td>
<!-- Required -->
<td align="left" valign="top">false</td>
<!-- Default -->
<td align="left" valign="top">&nbsp;</td>
<!-- Type -->
<td align="left" valign="top">Object/String</td>
<!-- Description -->
<td align="left" valign="top">Date or DateTime format pattern</td>
</tr>
<tr>
<!-- Attribute name -->
<td align="left" valign="top">nice</td>
<!-- Required -->
<td align="left" valign="top">false</td>
<!-- Default -->
<td align="left" valign="top">false</td>
<!-- Type -->
<td align="left" valign="top">Boolean</td>
<!-- Description -->
<td align="left" valign="top">Whether to print out the date nicely</td>
</tr>
<tr>
<!-- Attribute name -->
<td align="left" valign="top">name</td>
<!-- Required -->
<td align="left" valign="top"><b>true</b></td>
<!-- Default -->
<td align="left" valign="top">&nbsp;</td>
<!-- Type -->
<td align="left" valign="top">String</td>
<!-- Description -->
<td align="left" valign="top">The date value to format</td>
</tr>
<tr>
<!-- Attribute name -->
<td align="left" valign="top">id</td>
<!-- Required -->
<td align="left" valign="top">false</td>
<!-- Default -->
<td align="left" valign="top">&nbsp;</td>
<!-- Type -->
<td align="left" valign="top">Object/String</td>
<!-- Description -->
<td align="left" valign="top">id for referencing element. For UI and form tags it will be used as HTML id attribute</td>
</tr>
</table>
<!-- END SNIPPET: tagattributes -->
</p>
<p>
<center><a href="index.html">Back to Taglib Index</a></center>
</p>
</body>
</html>