public class Rounder extends Object implements Serializable, Cloneable
Constructor and Description |
---|
Rounder()
Defaults to decimals = null (no limitation).
|
Rounder(Integer decimals)
Defaults to mode = HALF_UP.
|
Rounder(Integer decimals,
RoundingMode mode)
Defaults to stripTrailingZeros = true.
|
Rounder(Integer decimals,
RoundingMode mode,
boolean stripTrailingZeros)
Full constructor.
|
Rounder(String representation)
Specific String constructor.
|
Modifier and Type | Method and Description |
---|---|
Rounder |
clone() |
boolean |
equals(Object obj) |
Integer |
getDecimals() |
RoundingMode |
getMode() |
int |
hashCode() |
boolean |
isStripTrailingZeros() |
BigDecimal |
round(BigDecimal in)
Performs rounding and striping.
|
void |
setDecimals(Integer decimals) |
void |
setMode(RoundingMode mode)
Null defaults to HALF_UP.
|
void |
setStripTrailingZeros(boolean stripTrailingZeros) |
BigDecimal |
strip(BigDecimal in)
Performs only striping.
|
static BigDecimal |
stripDecimalZeros(BigDecimal in) |
String |
toString() |
public Rounder()
public Rounder(Integer decimals)
public Rounder(Integer decimals, RoundingMode mode)
public Rounder(Integer decimals, RoundingMode mode, boolean stripTrailingZeros)
public Rounder(String representation)
RoundingMode
Value]{0,1}.IllegalArgumentException
- if representation does not represent a Rounder.public BigDecimal round(BigDecimal in)
public BigDecimal strip(BigDecimal in)
public static BigDecimal stripDecimalZeros(BigDecimal in)
public Integer getDecimals()
public void setDecimals(Integer decimals)
public RoundingMode getMode()
public final void setMode(RoundingMode mode)
public boolean isStripTrailingZeros()
public void setStripTrailingZeros(boolean stripTrailingZeros)