velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: How to use DateTool
Date Tue, 04 Apr 2006 19:33:29 GMT
Well, you have to actually use the tool in your templates, not just
add it to the context.  It doesn't magically format your dates for
you.  You have to tell it to format them (e.g. $date.format('long',
$bu.LastVisited) ).  The documentation provides examples of how to do
this and a thorough explanation of the methods available to you.

On 4/4/06, Dominik Bruhn <dominik@dbruhn.de> wrote:
> Hy,
> thanks to your response. I added the proposed code to my servlet but nothing
> happens. I use the following code to output the timestamp:
> $bu.LastVisited
>
> The function "getLastVisited" of the Class of $bu returns a "Date"-Object.
> This outputs the date in "normal" format, no matter whether DateTool is
> embedded or not. With embedded DateTool I tried the "$bu.LastVisited.long"
> but it simply outputs the string "$bu.LastVisited.long" and not the formated
> date.
>
> So how do I use this tool?
>
> Thanks
> TO
>
>
>
> Am Dienstag 04 April 2006 19:47 schrieb Nathan Bubna:
> > You don't have to use a toolbox to use any of the Generic Tools.  Just
> > create an instance and add it to your context before the context is
> > merged with the template:
> >
> > context.put("date", new DateTool());
> >
> > pretty simple.
> >
> > On 4/4/06, Dominik Bruhn <dominik@dbruhn.de> wrote:
> > > Hy,
> > > I want to use the DateTool (
> > > http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tool
> > >s/generic/DateTool.html ) in my VelocityApplet. I not using Struts. How do
> > > I tell Velocity to use this Tool when outputting Dates. Some tell me
> > > about a toolbox.xml, but I don't know hwere to place it and with which
> > > content. A simple copy of the jar-file to the classpath didn't help.
> > >
> > > Who can help?
> > >
> > > Thanks
> > > Dominik
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message