Hi David,

Thx for the reply. We've already built a pull tool for working with Dates.
One of the methods we have allows us to pass a Date and a format for display
purposes. In our application we need to show the date in at least 3
different but similiar formats. In order to help me I thought it would be
easy to set something like

#set $DateOne = "dd/MM/yy"
#set $DateTwo = "dd-MM-yyyy"
#set $DateThree = "dd/MM/yyyy HH:mm"

as globals and passing the String to the Pull tool such as

PullTool(ActualDate, $DateOne)

which should show something like the following on the screen

18/11/68

/colin


----- Original Message -----
From: "David Worms" <[EMAIL PROTECTED]>
To: "Turbine Users List" <[EMAIL PROTECTED]>
Sent: Monday, October 21, 2002 9:14 PM
Subject: Re: Velocity template


> What you need is to create a tool. It is pretty easy and work very well.
> Here is an example:
>
> public class DateTool implements ApplicationTool
> {
>      private static final Log log = LogFactory.getLog( Date.class );
>
>      private String date = null;
>
>      /**
>       * Initialize the UIManager object.
>       *
>       * @param data This is null, RunData or User depending upon
> specified tool scope.
>       */
>      public void init(Object data)
>      {
>          Date d = new GregorianCalendar().getTime();
>          DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
>          this.date = df.format(d);
>      }
>
>      public String getNow()
>      {
>          return date;
>      }
>
>      /**
>       * do nothing
>       */
>      public void refresh()
>      {
>      }
>
> }
>
> You can go to the pool how-to to see how to configure your TR.prop file
>
> David Worms
>
> On Monday, October 21, 2002, at 12:09 PM, Colin Chalmers wrote:
>
> > Hi all,
> >
> > Using Velocity with Tubine and would like to know if there's somewhere
> > I can set a *global* variable which is applicable to (almost) all
> > templates. I want to set a date format which I can use to show the
> > date in a number of templates. I tried to add a #set statement to the
> > global_macros file but things went wrong. Any ideas? Can't imagine I
> > have to add #set to each and every template.
> >
> > Any help appreciated.
> >
> > /Colin
>
>
> --
> To unsubscribe, e-mail:
<mailto:turbine-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
<mailto:turbine-user-help@;jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:turbine-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-user-help@;jakarta.apache.org>

Reply via email to