List of utility methods to do BigDecimal Trim
BigDecimal | trim(BigDecimal n) Returns the BigDecimal value n with trailing zeroes removed. try { while (true) { n = n.setScale(n.scale() - 1); } catch (ArithmeticException e) { return n; |
BigDecimal | trim(BigDecimal pNombre) trim BigDecimal nombreTronque = pNombre; try { while (true) { nombreTronque = nombreTronque.setScale(pNombre.scale() - 1); } catch (ArithmeticException e) return nombreTronque; |
String | trim(BigDecimal val) trim String valStr = String.valueOf(val.doubleValue()); return trim(valStr); |
BigDecimal | trimBigDecimal(BigDecimal n) trimBigDecimal ( (BigDecimal) a) to cut off all trailing zeros. if (n.unscaledValue().intValue() == 0) { return BigDecimal.ZERO; if (n.scale() <= 0) { return n; BigDecimal stripped = n.stripTrailingZeros(); if (stripped.scale() < 0) { ... |
BigDecimal | truncateAmount(BigDecimal value) truncate Amount return value.setScale(3, RoundingMode.FLOOR).stripTrailingZeros();
|
BigDecimal | truncByScale(BigDecimal value, int scale) trunc By Scale return value.setScale(scale, BigDecimal.ROUND_DOWN);
|