You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Bertrand VENZAL <be...@cirso.fr> on 2004/02/04 18:28:39 UTC

Réf. : Re: ParseLong



Hi,

Thanks for your help, i used the parseLong function, but (there is always a
but) I can not manipulate the long variable that i have defined. In fact, I
want to compare two long variable ( or doing a soustraction), and my vm
refuse to execute it, could you help me on this one.

Bertrand

PS: I don t know also how to use the NumberFormatTool object in a vm ....
|------------------------+------------------------+------------------------|
|                        |   Mike Kienenberger    |                        |
|                        |   <mk...@alaska.net>|           Pour :       |
|                        |   Envoyé par :         |   Velocity Users List  |
|                        |   velocity-user-return-|   <velocity-user@jakart|
|                        |   12748-bertrand.venzal|   a.apache.org>        |
|                        |   =cirso.fr@jakarta.apa|           cc :         |
|                        |   che.org              |           Objet :      |
|                        |                        |   Re: ParseLong        |
|                        |   04/02/2004 17:04     |                        |
|                        |   Veuillez répondre à  |                        |
|                        |   "Velocity Users List"|                        |
|                        |                        |                        |
|------------------------+------------------------+------------------------|






Yiannis Mavroukakis <yi...@jaguarfreight.com> wrote:
> Try this out
>
> Long lng = new Long("11223344556677");
> or
> Long lng = new Long(myLongString);
>
> and add this in your VelocityContext using the put(String arg0,Object
arg1)
> method.


I think you can also use the "LongVar =
NumberFormatTool.toNumber(StringExp)" tool method.

-Mike

---------------------------------------------------------------------
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


Re: Réf. : Re: ParseLong

Posted by Nathan Bubna <na...@esha.com>.
Bertrand VENZAL said:
> Thanks for your help, i used the parseLong function, but (there is always a
> but) I can not manipulate the long variable that i have defined. In fact, I
> want to compare two long variable ( or doing a soustraction), and my vm
> refuse to execute it, could you help me on this one.
>
> Bertrand
>
> PS: I don t know also how to use the NumberFormatTool object in a vm ....

you can find documentation on the MathTool and the NumberTool below:

http://jakarta.apache.org/velocity/tools/generic/

for manipulating Longs, you will want to use the MathTool (the NumberTool is
for formatting).

to use it, just put an instance in your context:

context.put("math", new MathTool());

right now, the MathTool doesn't have comparison methods per se, but you can
easily extend it to add comparison methods.

Nathan Bubna
nathan@esha.com


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


Re: Réf. : Re: ParseLong

Posted by Mike Kienenberger <mk...@alaska.net>.
Bertrand VENZAL <be...@cirso.fr> wrote:
> Thanks for your help, i used the parseLong function, but (there is always 
a
> but) I can not manipulate the long variable that i have defined. In fact, 
I
> want to compare two long variable ( or doing a soustraction), and my vm
> refuse to execute it, could you help me on this one.
> 
> Bertrand
> 
> PS: I don t know also how to use the NumberFormatTool object in a vm ....

To do Long arithmetic, you'll need to use the MathTool.

See the following link for details:

http://jakarta.apache.org/velocity/tools/

The quick summary is as follows:

You'll need to add the Velocity-Tools jar file in your project.
You will need to define the tools in the toolbox.xml file.

Then assuming you defined the MathTool as $math, you would do something like 


#set ($longResult = $math.sub($firstLong, $secondLong) )

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