How can I use the Pattern and Pattern Expression in the Textfield properties to reduce a java.lang.String value to have two decimal digits?
Any assitance would be appreciated .
2 Answers:
Posted on March 6, 2019 at 2:10am
There are a bunch of approaches, which depend on your java knowledge. For example, expressions:
A)
String.format("%.2f", new BigDecimal(Double.parseDouble($F{sample})))
B)
new DecimalFormat("0.00").format(new Double($F{sample}))
where $F{sample} is a field from dataset, that contains numbers. I used sample query:
SELECT '25.45060506506456' AS sample
Also, attaching report.
Attachments:
Attachment | Size |
---|---|
![]() | 2.16 KB |