List of utility methods to do BigDecimal
int | moveRight(BigDecimal value, int offset) move Right if (null == value) { return 0; return value.movePointRight(offset).intValue(); |
int | nullSafeCompare(BigDecimal pPremierNombre, BigDecimal pSecondNombre) null Safe Compare if (pPremierNombre == pSecondNombre) return 0; if (null == pPremierNombre) { return -1; if (null == pSecondNombre) { ... |
String | numberToWordsWithDecimal(BigDecimal value) number To Words With Decimal final String integerText = numberToWords(value.longValue(), false); String decimalText = value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString(); decimalText = decimalText.substring(decimalText.indexOf(".") + 1); return integerText + " and " + decimalText + "/100"; |
BigDecimal | nvl(final BigDecimal bigDecimal) Returns zero when the given BigDecimal is null return bigDecimal == null ? BigDecimal.ZERO : bigDecimal;
|
BigDecimal | nvlZero(BigDecimal num) nvl Zero return num == null ? BigDecimal.ZERO : num;
|
BigDecimal | objectToBigDecimal(Object object) Supports any object which toString method return a numeric as String. if (object == null) { return null; try { return new BigDecimal(object.toString()); } catch (NumberFormatException nfe) { return null; |
BigDecimal | objToBigDecimal(Object obj) obj To Big Decimal BigDecimal bigDec = null; if (obj != null) { bigDec = (BigDecimal) obj; return bigDec; |
String | PackUnit2Uom(BigDecimal packUit, String eachUnitName) Pack Unit Uom if (eachUnitName.compareTo("EA") == 0) { return String.format("H%02d", packUit.intValue()); } else if (eachUnitName.compareTo("KG") == 0) { return String.format("H%.4fK", packUit.floatValue()); } else if (eachUnitName.compareTo("G") == 0) { return String.format("H%.4fG", packUit.floatValue()); } else { return String.format("H%.4fN", packUit.floatValue()); ... |
BigDecimal | percent0(final BigDecimal c, final BigDecimal percent) percent BigDecimal res = c.multiply(percent); BigDecimal l100 = new BigDecimal("100"); BigDecimal res1 = res.divide(l100, 2, 0); return res1; |
String | percentage(BigDecimal bd) percentage return bd.multiply(HUNDRED).setScale(1, RoundingMode.HALF_UP).toString();
|