Below is the piece of code, I am trying to print 123 as 123.00
but it gives me 123
:
BigDecimal decimal = new BigDecimal(123);
decimal.doubleValue();
Can you please help me in printing 123 as 123.00
?
Try like this:
BigDecimal value = new BigDecimal(123);
value = value.setScale(2, BigDecimal.ROUND_HALF_EVEN)
You can refer Javadocs for ROUND_HALF_EVEN and setScale