john mahan said:
> Using Velocity Template I have tried a variety of DateTool
> (and MathTool) coding approaches without success (getting NULL result).

for everything you try?  are you sure you put them in the context?  what is
rendered when you do:

$math.class or $date.class ?

if that doesn't render the class names, then you haven't made those tools
available to your context.  you can do so either by adding them directly:

context.put("date", new DateTool())

or if you are using the VelocityViewServlet, you can register them in your
toolbox.xml:

<tool>
    <key>date</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.DateTool</class>
</tool>

if you don't know what the above examples mean, you need to be reading the
Velocity and/or VelocityTools documentation and perhaps checking out the
examples as well.

> The objective is to calculate a Date object comprised of current
> date plus a variable number of days that is converted to a string for
display;
>
> Here is an example of one approach I tried:
>
>
>  ## -------- Set Min Date
>
>      #set ($minDays = 2)  ## Earliest Day valid from Today (0= Today)
>      ## ------  Set Initial Calendar Date For Display
>      #set ($minDaysMS = ($minDays * 1000 * 60 * 60 * 24))
>      #set ($currDate = $date) ## Default Current System Date
>      #set ($baseDate = $date.format('S',$currDate))
>      #set ($minDateMS = ($baseDate + $minDaysMS))

this won't work.  you can't add a string ($baseDate) to an integer
($minDaysMS) in VTL.

>      #set ($minDateDisp = $date.toDate($minDateMS))

actually, this step won't work either.  the toDate() methods don't currently
take integers, only Long instances.  i'm gonna change this now that i think
about it, it shouldn't hurt anything to accept integers as well.

>      #set ($dateDisp = $date.format('M/d/yyyy',$minDateDisp))  ## Min Date
Short String


hope this helps.

Nathan Bubna
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to