examples

currency

package currency

Visibility
  1. Public
  2. All

Type Members

  1. class Currency extends Ordered[Currency]

    Represents an immutable, arbitrary-precision currency value with fixed point arithmetic.

    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 using java.math.BigDecimal, the Currency type gives users complete control over rounding behaviour. The default rounding more is ROUND_HALF_UP which is commonly used in commercial applications. The ROUND_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, the Currency class offers general purpose fixed-point arithmetic.

    Version

    1.0

    20090506 tk v first release 20100312 tk f fixed errors in country code map

  2. class MismatchedCurrencyException extends Exception

    This exception is thrown if an arithmetic operation is attempted on two values with currencies that don't match.

  3. class UnknownCurrencyException extends Exception

    This exception is thrown if a currency with an unknown ISO ISO 4217 currency code is created or requested.

Value Members

  1. object Currency

Ungrouped