org.apache.velocity.tools.generic Class DateTool
- public class DateTool
- extends java.lang.Object
Tool for working with
Calendar in Velocity templates. It is useful for accessing and formatting the "current" date as well as for formatting arbitrary
Calendar objects. Also the tool can be used to retrieve
DateFormat instances or make conversions to and from various date types.
Example uses: $date -> Oct 19, 2003 9:54:50 PM $date.long -> October 19, 2003 9:54:50 PM PDT $date.medium_time -> 9:54:50 PM $date.full_date -> Sunday, October 19, 2003 $date.get('default','short') -> Oct 19, 2003 9:54 PM $date.get('yyyy-M-d H:m:s') -> 2003-10-19 21:54:50 $myDate -> Tue Oct 07 03:14:50 PDT 2003 $date.format('medium',$myDate) -> Oct 7, 2003 3:14:50 AM Example toolbox.xml config (if you want to use this with VelocityView): <tool> <key>date</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.DateTool</class> </tool>
This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application). As such, the methods are highly interconnected, and overriding key methods provides an easy way to create subclasses that use a non-default format, calendar, locale, or timezone.
- VelocityTools 1.0
- $Revision: 154105 $ $Date: 2005-02-16 16:56:54 -0800 (Wed, 16 Feb 2005) $
- Nathan Bubna
For complete documentation on this viewtool use the following link: DateTool