0
votes

i am print a value in jasper report but it's not display decimal precision.

but display value this type 20.00000000 and i need a Only "20.00" decimal precision

how to solve it please replay

3
It will be fine if you tell us about your datasource - Viki888

3 Answers

3
votes

You can try the below expression

new DecimalFormat("#,##0.00").format($F{FieldValue})

Hope this should solve your problem

1
votes

Try with this entry into jasper file:

<textField pattern="###0.00;(###0.00)">
    <textFieldExpression class="java.lang.String"><![CDATA[$P{percentage_rate}]]></textFieldExpression>
</textField>

Second approach is via java code: Convert the value in 2 decimal place in java file that will be fetched by jasper file.

String percentage_rate = new BigDecimal(p_rate!=null ?p_rate:"0").setScale(2, RoundingMode.HALF_UP).toString();
0
votes

you can try using field pattern property(right click on field) and use pattern style according to your requirement.

right click on field ->field pattern ->(Category)Number ->you can chose the decimal places.

using ireport IDE Hope this helps