Hi
In my application there is a field "Period" of type BigDecimal. i need to check for a condition like,
($F{Period} != 0)?value1:value2
but it says, Incompatible operand types BigDecimal and int
and another condition like,
($F{Period} < 0)?value1:value2
but it gives me the following error,
the operator < is undefined for the argument type(s) BigDecimal, int
Can you please tell me what needs to be changed in my syntax. Please post your answers soon. Its very urgent. Thanks a lot.
Madhan!!!!
3 Answers:
No, operators like "not equal" don't work on objects like that. Rather than converting zero to a BigDecimal, you probably need to go the other way: convert the BigDecimal to an int. Like this:
($F{Period}.intValue() < 0)?value1:value2
Regards,
Matt
baggypants's idea could also work, but it's probably more difficult. It would be more like this:
($F{Period}.compareTo(new BigDecimal(0)) != 0) ? value1 : value2