I have to convert a BigDecimal
value, e.g. 2.1200
, coming from the database to a string. When I use the toString()
or toPlainString()
of BigDecimal
, it just prints the value 2.12
but not the trailing zeroes.
How do I convert the BigDecimal
to string without losing the trailing zeroes?
try this..
MathContext mc = new MathContext(6); // 6 precision
BigDecimal bigDecimal = new BigDecimal(2.12000, mc);
System.out.println(bigDecimal.toPlainString());//2.12000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With