final class BigDecimalConversion extends Object
BigDecimal
.Modifier and Type | Method and Description |
---|---|
static long |
bigDecimalToLong(RoundingMode roundingMode,
BigDecimal value)
Converts the specified big decimal value to a long value applying the
given rounding mode.
|
static long |
bigDecimalToUnscaled(ScaleMetrics scaleMetrics,
RoundingMode roundingMode,
BigDecimal value)
Converts the specified big decimal value to an unscaled decimal applying
the given rounding mode if necessary.
|
static BigDecimal |
unscaledToBigDecimal(ScaleMetrics scaleMetrics,
long uDecimal)
Converts the given unscaled decimal value to a
BigDecimal of the
same scale as the given decimal value. |
static BigDecimal |
unscaledToBigDecimal(ScaleMetrics scaleMetrics,
RoundingMode roundingMode,
long uDecimal,
int targetScale)
Converts the given unscaled decimal value to a
BigDecimal of the
specified targetScale rounding the value if necessary. |
public static final long bigDecimalToLong(RoundingMode roundingMode, BigDecimal value)
roundingMode
- the rounding mode to apply if necessaryvalue
- the big decimal value to convertIllegalArgumentException
- if the value is outside of the valid long rangeArithmeticException
- if roundingMode==UNNECESSARY
and rounding is
necessarypublic static final long bigDecimalToUnscaled(ScaleMetrics scaleMetrics, RoundingMode roundingMode, BigDecimal value)
scaleMetrics
- the scale metrics of the result valueroundingMode
- the rounding mode to apply if necessaryvalue
- the big decimal value to convertIllegalArgumentException
- if the value is outside of the valid Decimal rangeArithmeticException
- if roundingMode==UNNECESSARY
and rounding is
necessarypublic static final BigDecimal unscaledToBigDecimal(ScaleMetrics scaleMetrics, long uDecimal)
BigDecimal
of the
same scale as the given decimal value.scaleMetrics
- the scale metrics associated with the unscaled valueuDecimal
- the unscaled decimal value to convertpublic static final BigDecimal unscaledToBigDecimal(ScaleMetrics scaleMetrics, RoundingMode roundingMode, long uDecimal, int targetScale)
BigDecimal
of the
specified targetScale
rounding the value if necessary.scaleMetrics
- the scale metrics associated with the unscaled valueroundingMode
- the rounding mode to use if rounding is necessaryuDecimal
- the unscaled decimal value to converttargetScale
- the scale of the result valuetargetScale
ArithmeticException
- if roundingMode==UNNECESSARY
and rounding is
necessary