velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis <j...@respublica.fr>
Subject Re: comparing monetary value
Date Tue, 15 Oct 2002 11:11:37 GMT

On Tuesday, October 15, 2002, at 08:32  am, Konstantin Priblouda wrote:

>
> --- STham@thoughtworks.COM wrote:
>>
>> Hi,
>>
>>    I believed at the moment, all numbers are treated
>> as Integer. Anyone
>> came across this problem of manipulating with money
>> value before?
>>
>> Example :
>>
>>   Give a certain amount has to be less than a given
>> value.
>>
>>    if ($someMoneyValue < 0.01) ???
>>
>> How do people normally handle money in velocity??
>> Thanks.
>>
>> cheers,
>> shen
> AFAIK, velocity does not support comparisons on
> anything but integers. I worked around by providing
> convenience methods in my model beans.
> You may also create "comparator" bean, which will
> floats for you
> i.e:
> public class Foo {
> public boolean lessThan(float a, float b) {
>   return a < b;
> }
> }

The class Double already has the necessary hooks. If $number is a 
Double, you can use:

#if ($number.compareTo($number.parseDouble("0.01")) < 0)

-- Denis.

>
> then in velocity template:
> #if( $Foo.lessThan(a,0.01)
>
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik )    Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>


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


Mime
View raw message