EgovNumericUtil { public static String plus(String thisVal, String addVal) { String result = null; BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal); BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal); result = one.add(two).toString(); return result; } 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 testPlus() throws Exception { assertEquals("400", EgovNumericUtil.plus("151", "249")); assertEquals("400.0000", EgovNumericUtil.plus("151.7531", "248.2469")); assertEquals("400.000", EgovNumericUtil.plus("151.7531", "248.2469", 3)); assertEquals("399.9654", EgovNumericUtil.plus("151.7531", "248.2123")); assertEquals("399.966", EgovNumericUtil.plus("151.7531", "248.2123", 3, EgovNumericUtil.ROUND_UP)); assertEquals("399.965", EgovNumericUtil.plus("151.7531", "248.2123", 3, EgovNumericUtil.ROUND_DOWN)); assertEquals("399.97", EgovNumericUtil.plus("151.7531", "248.2123", 2, EgovNumericUtil.ROUND_HALF_UP)); }