Setting a number format pattern in iReport 5.7.0 to retain 3 digits after the decimal point

余生长醉 提交于 2021-02-17 05:37:25

问题


I am using iReport 5.7.0 to generate JasperReports's report.
I have set the pattern #####0.000 on a field with a Double value.
I have expected 3 decimal places But actually Only one zero after the decimal point is displayed if the number has no decimal part .
i.e , what I get `4.56678 =>4.566
4.0 =>4.0 4.1 => 4.000

What I want 4.5667888 =>4.566 4.0 =>4.000 4.1 =>4.000 `

Any help please ?


回答1:


Try following at the place where you want a particular decimal format. Say you have a field into report, Total_Number:

new DecimalFormat("#0.000").format($F{Total_number})

If the value for $F{Total_number} is 4.5667888. Following is the output:

Output

4.566


来源:https://stackoverflow.com/questions/25427382/setting-a-number-format-pattern-in-ireport-5-7-0-to-retain-3-digits-after-the-de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!