There are two things that can be improved in the code.
First, casting a double to BigDecimal to round it is very inefficient. Instead, you should use Math.round:
double value = 1.125879D; double valueRounded = Math.round(value * 100D) / 100D;
Secondly, when printing or converting a real number into a string, you can use System.out.printf or String.format. In your case, using the format "% .2f" does the trick.
System.out.printf("%.2f", valueRounded);
source share