Java Utililty Methods BigDecimal Trim

List of utility methods to do BigDecimal Trim

Description

The list of methods to do BigDecimal Trim are organized into topic(s).

Method

BigDecimaltrim(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;
BigDecimaltrim(BigDecimal pNombre)
trim
BigDecimal nombreTronque = pNombre;
try {
    while (true) {
        nombreTronque = nombreTronque.setScale(pNombre.scale() - 1);
} catch (ArithmeticException e) 
return nombreTronque;
Stringtrim(BigDecimal val)
trim
String valStr = String.valueOf(val.doubleValue());
return trim(valStr);
BigDecimaltrimBigDecimal(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) {
...
BigDecimaltruncateAmount(BigDecimal value)
truncate Amount
return value.setScale(3, RoundingMode.FLOOR).stripTrailingZeros();
BigDecimaltruncByScale(BigDecimal value, int scale)
trunc By Scale
return value.setScale(scale, BigDecimal.ROUND_DOWN);