Sunday, March 6, 2016

Jasper Report: How to divide BigDecimal number



The following example shows how to divide a BigDecimal format field.






















JumAset is a Jasper Report field with java.math.BigDecimal data type. Below is its screen shot:













Drag JumAset field into Detail Band. Below is the example:










Click at JumAset field under column header TOTAL OF ASSET IN MILLION, then go to Text Field expression and type the following expression:

$F{JumAset}.divide(new BigDecimal("1000000"))

Below is the screen shot:

Finally, compile and run the report and below is the example of output:















That’s all.

1 comment:

  1. how to divide decimal value with zero using if else condition.
    my condition is ($F{flat_area} == 0.00 ? 0.00: $F{CAM_charges}.divide($F{flat_area}))

    ReplyDelete