'how to convert String to Double in jasper Report?
How to convert String to Double value in jasper Reports? I am having two fields in .jrxml file like below
<field name="secRate" class="java.lang.String"/>
<field name="secPrice" class="java.lang.String"/>
i need to subtract both the field
$V{Variable} = $F{secRate} - SF{secPrice}
i tried this way but not working
(new Double(Double.parseDouble($F{mktVal})))
any idea? please help me guys..
Solution 1:[1]
- Set Text Field Expression:
Double.parseDouble($F{PARAM}) - Set Expression Class:
java.lang.Double - Add
rt.jar(from java runtime) to classpath [Tools >> Options >> Classpath] - And Compile
Solution 2:[2]
Try
Double.valueOf(${mktVal}).
Solution 3:[3]
Pls try this one - ($F{PARAM}.trim().isEmpty()) ? 0.0 : new Double($F{PARAM})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Florent |
| Solution 3 | Luca Kiebel |
