EgovNumericUtil { public static String minus(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.subtract(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 testMinus() throws Exception { assertEquals("89", EgovNumericUtil.minus("240", "151")); assertEquals("96.4938", EgovNumericUtil.minus("248.2469", "151.7531")); assertEquals("96.49380", EgovNumericUtil.minus("248.2469", "151.7531", 5)); assertEquals("96.4592", EgovNumericUtil.minus("248.2123", "151.7531")); assertEquals("96.460", EgovNumericUtil.minus("248.2123", "151.7531", 3, EgovNumericUtil.ROUND_UP)); assertEquals("96.459", EgovNumericUtil.minus("248.2123", "151.7531", 3, EgovNumericUtil.ROUND_DOWN)); assertEquals("96.46", EgovNumericUtil.minus("248.2123", "151.7531", 2, EgovNumericUtil.ROUND_HALF_UP)); }