|
|
|
|
| <html>
|
| <head>
|
| <title>Velocity - DateTool</title>
|
|
|
| <meta name="author" value="Gabriel Sidler"/>
|
| <meta name="email" value="sidler@apache.org" />
|
|
|
|
|
| </head>
|
|
|
| <body bgcolor="#ffffff" text="#000000" link="#525D76"
|
| alink="#525D76" vlink="#525D76">
|
|
|
| <table border="0" width="100%" cellspacing="4">
|
|
|
| <tr><td colspan="2">
|
|
|
| <a href="http://velocity.apache.org/">
|
| <img src="http://velocity.apache.org/images/velocity_project_wide.png"
|
| align="left" alt="The Velocity Project" border="0"/>
|
| </a>
|
|
|
|
|
|
|
| <a href="index.html">
|
| <img src="../images/velocitygenerictools.png" align="right" alt="< Velocity Tools - Library >" border="0"/>
|
| </a>
|
|
|
| </td></tr>
|
|
|
| <tr>
|
| <td colspan="2">
|
| <hr noshade="" size="1"/>
|
| </td>
|
| </tr>
|
|
|
| <tr>
|
|
|
| <td width="20%" valign="top" nowrap="true">
|
|
|
| <p><strong><a href="../">Velocity Tools</a></strong></p>
|
|
|
| <p>
|
| <strong>Generic Tools</strong>
|
| </p>
|
| <ul>
|
| <li><a href="index.html">Overview</a></li>
|
| <li><a href="../index.html#Download">Download</a></li>
|
| <li><a href="index.html#Contributions">Contributions</a></li>
|
| <li><a href="../javadoc/index.html">Javadoc</a></li>
|
|
|
| </ul>
|
| <p>
|
| <strong>Tool Documentation</strong>
|
| </p>
|
| <ul>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/ComparisonDateTool.html">ComparisonDateTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/DateTool.html">DateTool</a></li>
|
| <li><a href="MathTool.html">MathTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/NumberTool.html">NumberTool</a></li>
|
| <li><a href="RenderTool.html">RenderTool</a></li>
|
| <li><a href="EscapeTool.html">EscapeTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/ResourceTool.html">ResourceTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/Alternator.html">Alternator</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/AlternatorTool.html">AlternatorTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/ValueParser.html">ValueParser</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/ListTool.html">ListTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/SortTool.html">SortTool</a></li>
|
| <li><a href="../javadoc/org/apache/velocity/tools/generic/IteratorTool.html">IteratorTool</a></li>
|
|
|
| </ul>
|
| <p>
|
| <strong>Other Subprojects</strong>
|
| </p>
|
| <ul>
|
| <li><a href="../view/">VelocityView</a></li>
|
| <li><a href="../struts/">VelocityStruts</a></li>
|
|
|
| </ul>
|
|
|
| <p>
|
| </p>
|
|
|
| </td>
|
|
|
| <!-- RIGHT SIDE MAIN BODY -->
|
| <td colspan="1" valign="top" align="left">
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="DateTool Reference Documentation">
|
| <strong>DateTool Reference Documentation</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
| <p> |
| Tool for accessing, manipulating, and converting<code>java.util.Date</code> |
| and <code>java.util.Calendar</code> objects in Velocity templates. It |
| supports locales to format dates language and country specific. |
| </p>
|
| <table cellpadding="0" cellspacing="0">
|
| <tr><td colspan="2"><strong>Class</strong></td></tr>
|
| <tr><td> </td><td>org.apache.velocity.tools.generic.DateTool</td></tr>
|
|
|
| <tr><td colspan="2"><strong>Name</strong></td></tr>
|
| <tr><td> </td><td>$date (this is the recommended name of the tool in
|
| the Velocity context)</td></tr>
|
|
|
| <tr><td colspan="2"><strong>Toolbox Configuration Example</strong></td></tr>
|
| <tr><td> </td><td><pre><tool> |
| <key>date</key> |
| <scope>application</scope> |
| <class>org.apache.velocity.tools.generic.DateTool</class> |
| </tool></pre></td></tr>
|
|
|
| <tr><td colspan="2"><strong>Author(s)</strong></td></tr>
|
| <tr>
|
| <td> </td>
|
| <td>Nathan Bubna<br></td>
|
| </tr>
|
| </table>
|
| <dl>
|
| <dt><strong>Method Overview</strong></dt>
|
| <dd>
|
| <table cellpadding="2" cellspacing="2" border="0">
|
| <tr>
|
| <td bgcolor="EEEEEE" nowrap>
|
| <a href="#getDate()">getDate()</a></td>
|
| <td bgcolor="EEEEEE">
|
| |
| Returns a Date object representing the time at which this |
| method was invoked. |
|
|
| </td>
|
| </tr>
|
| <tr>
|
| <td bgcolor="EEEEEE" nowrap>
|
| <a href="#getCalendar()">getCalendar()</a></td>
|
| <td bgcolor="EEEEEE">
|
| |
| Returns a Calendar object representing the time at which this |
| method was invoked. |
|
|
| </td>
|
| </tr>
|
| <tr>
|
| <td bgcolor="EEEEEE" nowrap>
|
| <a href="#format()">format()</a></td>
|
| <td bgcolor="EEEEEE">
|
| |
| Returns a formatted string representing the specified date. |
|
|
| </td>
|
| </tr>
|
| <tr>
|
| <td bgcolor="EEEEEE" nowrap>
|
| <a href="#toDate()">toDate()</a></td>
|
| <td bgcolor="EEEEEE">
|
| |
| Returns a Date object representing the specified date. |
|
|
| </td>
|
| </tr>
|
| <tr>
|
| <td bgcolor="EEEEEE" nowrap>
|
| <a href="#toCalendar()">toCalendar()</a></td>
|
| <td bgcolor="EEEEEE">
|
| |
| Returns a Calendar object representing the specified date. |
|
|
| </td>
|
| </tr>
|
| </table>
|
| </dd>
|
| </dl>
|
|
|
| </td>
|
| </tr>
|
| </table>
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="getDate()">
|
| <strong>getDate()</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
|
|
| <p>
|
| <abstract> |
| Returns a Date object representing the time at which this |
| method was invoked. |
| </abstract>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String getDate() |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String getDate(Locale locale) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <dl>
|
| <dt><strong>Parameters</strong></dt>
|
| <dd>
|
| <dl>
|
| <dt>locale</dt>
|
| <dd>
|
| <parameter name="locale"> |
| An object of class <code>java.util.Locale</code> that represents the locale |
| to be used to create the date. |
| </parameter>
|
| </dd>
|
|
|
|
|
| </dl>
|
| </dd>
|
| </dl>
|
| <dl>
|
| <dt><strong>Returns</strong></dt>
|
| <dd>
|
| <returns> |
| An object of class <code>java.util.Date</code> representing the time at which this |
| method was invoked in the specified locale. If no locale is specified, |
| the system's default locale is used. |
| </returns>
|
| </dd>
|
| </dl>
|
|
|
|
|
| <br clear="all">
|
|
|
| </td>
|
| </tr>
|
| </table>
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="getCalendar()">
|
| <strong>getCalendar()</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
|
|
| <p>
|
| <abstract> |
| Returns a Calendar object representing the time at which this |
| method was invoked. |
| </abstract>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String getCalendar() |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String getCalendar(Locale locale) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <dl>
|
| <dt><strong>Parameters</strong></dt>
|
| <dd>
|
| <dl>
|
| <dt>locale</dt>
|
| <dd>
|
| <parameter name="locale"> |
| An object of class <code>java.util.Locale</code> that represents the locale |
| to be used to create the calendar. |
| </parameter>
|
| </dd>
|
|
|
|
|
| </dl>
|
| </dd>
|
| </dl>
|
| <dl>
|
| <dt><strong>Returns</strong></dt>
|
| <dd>
|
| <returns> |
| An object of class <code>java.util.Calendar</code> representing the time at which this |
| method was invoked in the specified locale. If no locale is specified, |
| the system's default locale is used. |
| </returns>
|
| </dd>
|
| </dl>
|
|
|
|
|
| <br clear="all">
|
|
|
| </td>
|
| </tr>
|
| </table>
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="format()">
|
| <strong>format()</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
|
|
| <p>
|
| <abstract> |
| Returns a formatted string representing the specified date. |
| </abstract>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String format(String format, Object obj) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| String format(String format, Object obj, Locale locale) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <dl>
|
| <dt><strong>Parameters</strong></dt>
|
| <dd>
|
| <dl>
|
| <dt>format</dt>
|
| <dd>
|
| <parameter name="format"> |
| A string that represents the formatting instructions according to |
| <code>java.text.SimpleDateFormat</code>. See also below. |
| </parameter>
|
| </dd>
|
|
|
| <dt>obj</dt>
|
| <dd>
|
| <parameter name="obj"> |
| An object of class <code>java.util.Date</code> or <code>java.util.Calendar</code>. It is |
| also possible to pass a string that represents a parsable date |
| according to <code>java.text.DateFormat</code>. |
| </parameter>
|
| </dd>
|
|
|
| <dt>locale</dt>
|
| <dd>
|
| <parameter name="locale"> |
| An object of class <code>java.util.Locale</code> that represents the locale |
| to format the date for. |
| </parameter>
|
| </dd>
|
|
|
|
|
| </dl>
|
| </dd>
|
| </dl>
|
| <dl>
|
| <dt><strong>Returns</strong></dt>
|
| <dd>
|
| <returns> |
| The formatted date string in the specified locale or <code>null</code> |
| if one or several input parameters are invalid. If no locale is specified, |
| the system's default locale is used instead. |
| </returns>
|
| </dd>
|
| </dl>
|
|
|
| <p>This methods use the same formatting instructions as class |
| <code>java.text.SimpleDateFormat</code>.</p>
|
| <table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000">
|
| <table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF">
|
| <pre><sourcecode> |
| Symbol Meaning Presentation Example |
| ------ ------- ------------ ------- |
| G era designator (Text) AD |
| y year (Number) 1996 |
| M month in year (Text & Number) July & 07 |
| d day in month (Number) 10 |
| h hour in am/pm (1~12) (Number) 12 |
| H hour in day (0~23) (Number) 0 |
| m minute in hour (Number) 30 |
| s second in minute (Number) 55 |
| S millisecond (Number) 978 |
| E day in week (Text) Tuesday |
| D day in year (Number) 189 |
| F day of week in month (Number) 2 (2nd Wed in July) |
| w week in year (Number) 27 |
| W week in month (Number) 2 |
| a am/pm marker (Text) PM |
| k hour in day (1~24) (Number) 24 |
| K hour in am/pm (0~11) (Number) 0 |
| z time zone (Text) Pacific Standard Time |
| ' escape for text (Delimiter) |
| '' single quote (Literal) ' |
| |
| Examples: "E, MMMM d" will result in "Tue, July 24" |
| "EEE, M-d (H:m)" will result in "Tuesday, 7-24 (14:12)" |
| </sourcecode></pre>
|
| </td></tr></table>
|
| </td></tr></table>
|
|
|
|
|
| <br clear="all">
|
|
|
| </td>
|
| </tr>
|
| </table>
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="toDate()">
|
| <strong>toDate()</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
|
|
| <p>
|
| <abstract> |
| Returns a Date object representing the specified date. |
| </abstract>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| Date toDate(Object obj) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <dl>
|
| <dt><strong>Parameters</strong></dt>
|
| <dd>
|
| <dl>
|
| <dt>obj</dt>
|
| <dd>
|
| <parameter name="obj"> |
| The date to convert. The parameter can be an object of class |
| <code>java.util.Date</code> or <code>java.util.Calendar</code>. It is also possible to |
| pass a string that represents a parsable date according to |
| <code>java.text.DateFormat</code>. |
| </parameter>
|
| </dd>
|
|
|
|
|
| </dl>
|
| </dd>
|
| </dl>
|
| <dl>
|
| <dt><strong>Returns</strong></dt>
|
| <dd>
|
| <returns> |
| An object of class <code>java.util.Date</code> representing the converted date |
| or <null/> of the input parameter is invalid. |
| </returns>
|
| </dd>
|
| </dl>
|
|
|
|
|
| <br clear="all">
|
|
|
| </td>
|
| </tr>
|
| </table>
|
| <table border="0" cellspacing="0" cellpadding="2" width="100%">
|
| <tr>
|
| <td colspan="2" bgcolor="#525D76">
|
| <font color="#ffffff" face="arial,helvetica.sanserif">
|
| <a name="toCalendar()">
|
| <strong>toCalendar()</strong></a></font>
|
| </td>
|
| </tr>
|
| <tr>
|
| <td NOWRAP> </td>
|
| <td>
|
|
|
| <p>
|
| <abstract> |
| Returns a Calendar object representing the specified date. |
| </abstract>
|
| </p>
|
| <p>
|
| <table width="100%"><tr><td bgcolor="EEEEEE">
|
| <font size="+1"><code>
|
| <signature> |
| Calendar toCalendar(Object obj) |
| </signature>
|
| </code></font>
|
| </td></tr></table>
|
| </p>
|
| <dl>
|
| <dt><strong>Parameters</strong></dt>
|
| <dd>
|
| <dl>
|
| <dt>obj</dt>
|
| <dd>
|
| <parameter name="obj"> |
| The date to convert. The parameter can be an object of class |
| <code>java.util.Date</code> or <code>java.util.Calendar</code>. It is also possible to |
| pass a string that represents a parsable date according to |
| <code>java.text.DateFormat</code>. |
| </parameter>
|
| </dd>
|
|
|
|
|
| </dl>
|
| </dd>
|
| </dl>
|
| <dl>
|
| <dt><strong>Returns</strong></dt>
|
| <dd>
|
| <returns> |
| An object of class <code>java.util.Calendar</code> representing the converted date |
| or <null/> of the input parameter is invalid. |
| </returns>
|
| </dd>
|
| </dl>
|
|
|
|
|
| <br clear="all">
|
|
|
| </td>
|
| </tr>
|
| </table>
|
|
|
| </td>
|
|
|
| </tr>
|
|
|
| <!-- FOOTER SEPARATOR -->
|
| <tr>
|
| <td colspan="2">
|
| <hr noshade="" size="1"/>
|
| </td>
|
| </tr>
|
|
|
| <!-- PAGE FOOTER -->
|
| <tr><td colspan="2">
|
| <div align="center"><font color="#525D76" size="-1"><em>
|
| Copyright © 1999-2003, Apache Software Foundation
|
| </em></font></div>
|
| </td></tr>
|
|
|
| </table>
|
| </body>
|
| </html>
|