Manu
Manu

Reputation: 3247

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

Upvotes: 1

Views: 35075

Answers (4)

Vijay N
Vijay N

Reputation: 1

Pls try this one - ($F{PARAM}.trim().isEmpty()) ? 0.0 : new Double($F{PARAM})

Upvotes: 0

Dhrumil Shah
Dhrumil Shah

Reputation: 2176

Try

Double.valueOf(${mktVal}).

Upvotes: 0

neruv
neruv

Reputation: 19

  1. Set Text Field Expression: Double.parseDouble($F{PARAM})
  2. Set Expression Class: java.lang.Double
  3. Add rt.jar (from java runtime) to classpath [Tools >> Options >> Classpath]
  4. And Compile

Upvotes: 1

Giorgos Dimtsas
Giorgos Dimtsas

Reputation: 12609

If the mktVal field is a String, you can try using Double.valueOf(${mktVal}).

Upvotes: 7

Related Questions