in Velocity 1.5 or earlier, you can just use:

#set( $String = '' )
#set( $foo = $String.format('%.1f', $dataFedIn) )

because you can always call static methods on instances. :)

however, since there are some static classes of which you cannot
create instances (e.g. java.util.Math), we added support in 1.6 for
static class methods sans instances:

context.put("String", String.class);
---
#set( $foo = $String.format('%.1f', $dataFedIn) )

so, again, i would recommend upgrading to 1.6-beta2.  it also happens
to be faster, use less memory and have many less bugs than 1.5. :)

On Mon, Nov 17, 2008 at 3:01 PM, Mark Fenbers <[EMAIL PROTECTED]> wrote:
> It seems as though Velocity does not allow use of static functions.  Is this
> true?  For example, I want to use printf-like formatting on some data I feed
> into the template such as this:
>
> String.format("%.1f",$dataFedIn)
>
> Is there an alternative way to format data?  Or to use static functions?
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to