How to Round Numeric Value

Since the numerical elements are of a type java.math.BigDecimal, you can use setScale function for rounding:

resultPrice.setScale(2, 4)   // 4 = ROUND_HALF_UP

For details see: http://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html#setScale-int-int-

Found an issue in documentation? Write to us.

Â