Search code examples
javafloating-pointjasper-reportsformatted

java code to display a floating point value in specified format in jasper report


The value 13.10 is printed as 13.1 in my jasper report , I want to print it as 13.10 itself , How to do it .The corresponding JRXML statement is

<textFieldExpression class="java.lang.Float"><![CDATA[$F{temp_bill_tax}]]> 
</textFieldExpression>

Solution

  • If you are using iReport to create your jrxml. Right click your textfield, go to the "Text Field" tab, and in the Pattern combo box you select #,##0.00.

    Or add the pattern attribute in the field:

    <textField ... pattern="#,##0.00"  >
        <textFieldExpression class="java.lang.Float"><![CDATA[$F{temp_bill_tax}]]>/>
    </textField>