Monday 25 July 2016

Tip: Get two numbers after decimal point for Big Decimals or Doubles in Jasper Reports By converting to String

Hi,
This tip is useful to extract 2 numbers after decimal points in Jasper Reports

Syntax : 
 String.format("%.2f", (double)value);


 String.format("%.2f",(double)($F{UnitSales}.doubleValue()*$F{Rate}.doubleValue()))

456.325 * 2.376
Sample Result : 1084.2282 

After applying the above format in expression editor of text field in jasper 
The result would be : 1084.22

References :
http://stackoverflow.com/questions/50532/how-do-i-format-a-number-in-java

No comments:

Post a Comment