Here you can find the source of add(BigDecimal number1, BigDecimal number2, int decimalPlaces)
private static BigDecimal add(BigDecimal number1, BigDecimal number2, int decimalPlaces)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; public class Main { private static final MathContext mathContext = MathContext.DECIMAL128; private static final RoundingMode roundingMode = RoundingMode.HALF_UP; private static BigDecimal add(BigDecimal number1, BigDecimal number2, int decimalPlaces) { return number1.add(number2, mathContext).setScale(decimalPlaces, roundingMode); }// w w w . j a v a 2 s . c om }