My question is about of toString()
and toPlainString()
methods of the BigDecimal
dataTypewhich produces the output like
750.0000
150.0000
... etc
My question is how to specify the number of zeros followed after the dot? Is there a way to do it instead of String.replace(".0000", ".00")
method?
Apart from decimal format you can also use setScale(2)
like this
new BigDecimal("1.0000").setScale(2)
Also setScale allows you can specify the Rounding Mode