Here you can find the source of getStringValue(BigDecimal val, int newScale, int roundingMode)
public static String getStringValue(BigDecimal val, int newScale, int roundingMode)
//package com.java2s; import java.math.BigDecimal; public class Main { public static String getStringValue(BigDecimal val, int newScale, int roundingMode) { if (val.compareTo(new BigDecimal(val.intValue())) == 0) { val = val.setScale(0); } else {/*from ww w . ja v a2s . c om*/ val = val.setScale(newScale, roundingMode); } return "" + val; } }