Skip to main content
This revision made January 07, 2013 19:52, by Anatole


JSR 354 - Currency and Money


Introduction

This JSR focuses on defining interfaces and classes to be used for currencies and monetary amounts. Generally the following areas are defined:

  • Core This area defines the classes representing currencies and monetary amounts.
  • Conversion This area deals with exchange rates between currencies and provides an API/SPI to perform conversion of monetary amounts from one currency to another.
  • Format This area defines APIs/SPIs for formatting and parsing of currencies and monetary amounts, providing support for complex usage scenarios.

It is planned the the JSR will support both SE and ME environments. The reference implementation probably also will include further support for EE/CDI.

Scope and Use Cases

Generally the scope of the JSR is targeting all general application types, e.g.

  • eCommerce
  • Banking and finance
  • Investment
  • Insurance and Pension
  • etc.

Summarizing the scope can be defined as follows:

  • Provide abstractions for currency and money suitable for all target applications
  • Enhance, renew Currency, add support for non-ISO currencies
  • Support complex calculation rules including calculation precision and display precision
  • Support for regional rounding rules
  • Basic support for foreign exchange, extendable for more complex usage scenarios
  • A plain text representation of Money
  • Printing/Parsing to String
  • Support for pluralization
  • Provide APIs for historic access of currencies and exchange rates.
  • Define a flexible query API tu support complex usage scenarios for exchange rates and currencies

Nevertheless there are some restrictions (features that are not in scope):

  • It is not planned to target low latency such as Algorithmic Trading applications. Nevertheless we will try to keep performance in mind to accomodate such applications.
  • Storing a value in multiple currencies (a single value type that is effectively a map of currency to amount, where the amounts are all notionally the same by some form of currency conversion)
  • Large exchange rate system (as in a system suitable for trading, such as bid/ask)
  • Non-decimal currencies http://en.wikipedia.org/wiki/Non-decimal_currency#Contemporary_non-decimal_currencies

Additionally the following features have been considered as optional:

  • Providing static calculation utilities to those developers not using the JSR Money class (eg. those using an unwrapped double/long direcly).

The use cases derived can be found here.

Further Information and Source Code Access

Difference compared to previous revision
* Overall [[DesignPrinciples|Design Principles]] * Discussions about [[Precision]] and other [[implementation|Implementation notes]] * [[Requirements|Requirements]] * Public Source Code Repository on GitHub: [https://github.com/JavaMoney/javamoney GitHub Repository] ==External Links and Interesting Resources ===Links * [http://www.javapractices.com/topic/TopicAction.do?Id=13 Java Practices -> Representing Money] * [http://www.javaranch.com/journal/2003/07/MoneyInJava.html Working with Money in Java] * [http://www.jscience.org/api/org/jscience/economics/money/package-summary.html#package_description JScience support for monetary quantities and their currencies] * [http://www.eclipse.org/uomo UOMo Business, based on ICU4J and concepts by JScience Economics] * [http://download.nightlabs.de/jfire/builds/modules/JFire-Max/HEAD/apidocs/org/nightlabs/jfire/accounting/package-summary.html JFire Accounting] an [http://download.nightlabs.de/jfire/builds/modules/JFire-Max/HEAD/apidocs/org/nightlabs/l10n/Curr=
JSR 354 - Currency and Money


== Introduction This JSR focuses on defining interfaces and classes to be used for currencies and monetary amounts. Generally the following areas are defined: * '''Core''' This area defines the classes representing currencies and monetary amounts. ... * Discussions about [[Precision]] and other [[implementation|Implementation notes]] * [[Requirements|Requirements]] * Public Source Code Repository on GitHub: [https://github.com/JavaMoney/javamoney GitHub Repository] * [[AdditionalRency.html JFire Currency Interface] for reasons similar to those Stephen outlines below, JFire uses '''long''' directly, holding the "minor" amount, formatting it to the necessary representation> * [http://moneydance.com/dev/apidoc/index.html MoneyDance esources|API] for reasons similar to those Stephen outlines, MoneyDance API '''long''' directly, holding the "minor" amount. All formatting or currency exchange is done accordingly.
*
[http://joda-money.sourceforge.net/ Joda Money] can be referred to as an inspiration for API and design style. it is based on real-world use cases in an e-commerce application for airlines
(must be from a small or US airline, as there is no currency conversion;-)
''Note from Joda author Stephen Colebourne:'' my current company wants estimated amounts at high performance, so uses '''double''' directly * [https://github.com/ricardojmendez/grails-currencies Grails Currencies] uses BigDecimal as internal representation, but API only exposes '''Number''' in all Money operations like ''plus()'', ''minus()'' or similar.
* [http://wiki.eclipse.org/ICU4J ICU4J] Uses '''Number''' for all operations and internal storage in its Money type.
* [http://lemnik.wordpress.com/2011/03/25/bigdecimal-and-your-money/ Why not to use BigDecimal for Money]
* [http://thenextweb.com/africa/2012/02/05/learning-from-kenya-mobile-money-transfer-and-co-working-spaces/?awesm=tnw.to_1DEWI M-Pesa-Mobile Money in Africa]
* [http://www.xencraft.com/resources/multi-currency.html Currency Internationalization (i18n), Multiple Currencies and Foreign Exchange (FX).
* [http://en.wikipedia.org/wiki/Japanese_units_of_measurement#Money]: Discussion of internationalization of currencies, rounding, grouping and formatting, separators etc]
* [http://speleotrove.com/decimal/] * [http://sourceforge.net/projects/oquote/ ]: It has an interesting Currency and CurrencyAmount structure in it, too. Maybe a good inspiration, and given it is aimed at the UK and International Insurance industry, it sounds like a welcome project to get in touch with. Contains specifications for decimal floating point arithmetic-Werner Keil
* [http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba Algorithm for Fast Big Decimal Multiplication] ===
Related Initiatives * [http://timeandmoney.sourceforge.net/ Eric Evans Time and Money Library]
* [http://sourceforge.net/projects/bitcoin-client/ BitCoin Java Client

* [http://www.objectivelogic.com/resources/Java%20and%20Monetary%20Data/Java%20and%20Monetary%20Data.pdf Java and Monetary Data (PDF)]
 
 
Close
loading
Please Confirm
Close