@Test @SuppressWarnings("unchecked") public void testDivide() throws Exception { assertEquals("1.25", EgovNumericUtil.divide("15", "12")); Class<Exception> exceptionClass = null; try { assertEquals("1.2232931726907630522088353413655", EgovNumericUtil.divide("15.23", "12.45")); } catch (Exception e) { LOGGER.error("### Exception : {}", e.toString()); exceptionClass = (Class<Exception>) e.getClass(); } finally { assertEquals(ArithmeticException.class, exceptionClass); } assertEquals("1.22", EgovNumericUtil.divide("15.23", "12.45", 5)); assertEquals("1.224", EgovNumericUtil.divide("15.23", "12.45", 3, EgovNumericUtil.ROUND_UP)); assertEquals("1.223", EgovNumericUtil.divide("15.23", "12.45", 3, EgovNumericUtil.ROUND_DOWN)); assertEquals("1.22", EgovNumericUtil.divide("15.23", "12.45", 2, EgovNumericUtil.ROUND_HALF_UP)); }
public static String divide(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.divide(two).toString(); return result; }
EgovNumericUtil { public static String divide(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.divide(two).toString(); return result; } }
EgovNumericUtil { public static String divide(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.divide(two).toString(); return result; } protected  EgovNumericUtil(); }
EgovNumericUtil { public static String divide(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.divide(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); }
EgovNumericUtil { public static String divide(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.divide(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; }