Represents an immutable, arbitrary-precision currency value with fixed point arithmetic.
This exception is thrown if an arithmetic operation is attempted on two values with currencies that don't match.
This exception is thrown if a currency with an unknown ISO ISO 4217 currency code is created or requested.
Represents an immutable, arbitrary-precision currency value with fixed point arithmetic.
A
Currency
value consists of a numeric value, an optional currency designation, and an optional number of decimal places. The default number of positions after the decimal point is 2 or respectively the number of decimal places commonly used for the specified currency.Its numeric value is internally represented by a 128-bit
java.math.BigDecimal
with 34 significant decimal places. This allows high-precision computations over a large range of values. As an added benefit of usingjava.math.BigDecimal
, theCurrency
type gives users complete control over rounding behaviour. The default rounding more isROUND_HALF_UP
which is commonly used in commercial applications. TheROUND_HALF_EVEN
mode may be useful for statistical applications.Computations are carried out with a precision of n positions after the decimal point, whereas n is specified by the
decimals
parameter. The position at n + 1 is rounded according to the specified rounding mode.The
Currency
class distinguishes between specific and non-specific currencies. Specific currencies carry a designation that is specified by the respective ISO 4217 three-letter currency code. Non-specific values are values without currency code. Non-specific values can be added to or subtracted from specific values. Used with non-specific values only, theCurrency
class offers general purpose fixed-point arithmetic.1.0
20090506 tk v first release 20100312 tk f fixed errors in country code map