EgovNumericUtil { public static String setScale(String thisVal, int scale, int roundMode) { BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal); return one.setScale(scale, roundMode).toString(); } protected  EgovNumericUtil(); static boolean isNumber(String source); static String plus(String thisVal, String addVal); static String plus(String thisVal, String addVal, int scale); static String plus(String thisVal, String addVal, int scale, int roundMode); static String minus(String thisVal, String addVal); static String minus(String thisVal, String addVal, int scale); static String minus(String thisVal, String addVal, int scale, int roundMode); static String multiply(String thisVal, String addVal); static String multiply(String thisVal, String addVal, int scale); static String multiply(String thisVal, String addVal, int scale, int roundMode); static String divide(String thisVal, String addVal); static String divide(String thisVal, String addVal, int roundMode); static String divide(String thisVal, String addVal, int scale, int roundMode); static String setScale(String thisVal, int scale, int roundMode); static final int ROUND_UP; static final int ROUND_DOWN; static final int ROUND_HALF_UP; static final int ROUND_UNNECESSARY; }
@Test public void testScale() throws Exception { assertEquals("151.754", EgovNumericUtil.setScale("151.7531", 3, EgovNumericUtil.ROUND_UP)); assertEquals("151.753", EgovNumericUtil.setScale("151.7531", 3, EgovNumericUtil.ROUND_DOWN)); assertEquals("151.753", EgovNumericUtil.setScale("151.7531", 3, EgovNumericUtil.ROUND_HALF_UP)); }