What is JSR 354?
JSR 354 provides a portable and extendible framework for handling of Money & Currency. The API
models monetary amounts and currencies in a platform independent and portable way, including well
defined extension points. It's API defines a simple yet flexible contract that enables users to choose
the implementation matching their target requirements best and having full control about the numeric state
at all stages during monetary processing.
The JSR is lead by Anatole Tresch (Credit Suisse) (@atsticks).
You can access the API by adding the following Maven
dependencies:
<dependency>
<groupId>javax.money</groupId>
<artifactId>money-api</artifactId>
<version>1.0-RC1</version>
</dependency>
Further versions can be found here.
Though it is possible to compile your programs completely with the API, in most cases, you will also have to add an implementation, e.g. the Moneta reference implementation.
The release artifacts should be accessible from the following repositories:
- Maven Central
- JCenter by Bintray
Overview
The API basically consists of three packages:
- javax.money contains the main artifacts of the API, e.g. the interfaces for
MonetaryAmount, CurrencyUnit, MonetaryOperator, MonetaryQuery, and the accessor singletons for amounts, currencies and roundings. - javax.money.format contains the formatting logic, which has some similarities with
java.textbut relies more on immutable artifacts and builders. - javax.money.spi contains the service provider interfaces and the bootstrap logic, which allows to configure the API also within EE contexts (e.g. running it within a CDI container).
Documentation
Since it a Java Specification Request check out out JSR's specification from the JSR 354 Detail Page.