CurrencyUnitdoes not provide methods for localization (functionality is separated into dedicated
CurrencyUnitalways must provide the following properties:
CurrencyUnitcan optionally provide the following properties:
validFromtimestamp, defining from when the currency is valid (used for historic currencies).
validUntiltimestamp, defining until when the currency is valid (used for historic currencies).
CurrencyUnits can be accessed from the
CurrencyUnitProvideris provided by the
CurrencyUnitcan be accessed using
CurrencyUnitaccessed is not available, a
IllegalArgumentExceptionshould be thrown.
boolean isCurrencyAvailableallows to check if a
CurrencyUnitis available given the requested parameters.
CurrencyUnitinstances available for a given namespace, either
Region, which defines a grouping that may be different to the grouping defined by
MonetaryAmountnever rounds the internal numeric representation to avoid loosing information.
MonetaryAmountcan be created using a
MonetaryAmountdirectly provides arithmetic operations retuning the result as new immutable instance of
MonetaryAmount, that has a different
CurrencyMismatchException(runtime exception) must be thrown. Implicit conversion is not allowed.
MonetaryAmountsupports converting the numeric value using
short toShort(); double toDouble();etc.
MonetaryAmountsupports conversion into the corresponding numeric wrapper classes by a method
BigIntegeris also supported.
MonetaryAmountcan be queried for its internal number representation by calling
MonetaryAmountwith different numeric representations. By default the representation of the result equals to the target
MonetaryAmount, on which the operation was performed.
Five hundred dollars and fifty three cents– useful when producing statements and printing cheques in financial applications. SJC - this is a hard requirement in I18N terms, and something that could be added on top of the main API and separate to the JSR.
GBP 541.53should be able to format itself as
Five hundred and forty one pounds fifty three pence, but also as
£ 541.53p. Put another way currency should also hold its currency symbols, placement rules (many currencies use suffix notation) and probably the natural names for the currency components, so “pounds” and “pence” in the example above.