About
Joda-Money provides a library of classes to store amounts of money.
The JDK provides a standard currency class, but not a standard representation of money. Joda-Money fills this gap, providing the value types to represent money.
Joda-Money is licensed under the business-friendly Apache 2.0 licence.
Features
A selection of key features:
CurrencyUnit
- representing a currencyMoney
- a fixed precision monetary value typeBigMoney
- a variable precision monetary type- A customizable formatter
Documentation
Various documentation is available:
- The helpful user guide
- The Javadoc
- The change notes for each release
- The GitHub source repository
Why Joda Money?
Joda-Money provides simple value types, representing currency and money.
The project does not provide, nor is it intended to provide, monetary algorithms beyond the most basic and obvious. This is because the requirements for these algorithms vary widely between domains. This library is intended to act as the base layer, providing classes that should be in the JDK.
As a flavour of Joda-Money, here is some example code:
// create a monetary value Money money = Money.parse("USD 23.87"); // add another amount with safe double conversion CurrencyUnit usd = CurrencyUnit.of("USD"); money = money.plus(Money.of(usd, 12.43d)); // subtracts an amount in dollars money = money.minusMajor(2); // multiplies by 3.5 with rounding money = money.multipliedBy(3.5d, RoundingMode.DOWN); // compare two amounts boolean bigAmount = money.isGreaterThan(dailyWage); // convert to GBP using a supplied rate BigDecimal conversionRate = ...; // obtained from code outside Joda-Money Money moneyGBP = money.convertedTo(CurrencyUnit.GBP, conversionRate, RoundingMode.HALF_UP); // use a BigMoney for more complex calculations where scale matters BigMoney moneyCalc = money.toBigMoney();
Releases
The 2.x branch (v2.0.0) is compatible with Java SE 21 or later.
The 1.x branch (v1.0.5) is compatible with Java SE 8 or later.
v2.x releases are compatible with v1.x releases - except for the Java SE version and module-info.class
file.
Joda-Money has no mandatory dependencies. There is a compile-time dependency on Joda-Convert, but this is not required at runtime thanks to the magic of annotations.
Available in Maven Central. GitHub release bundles.
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-money</artifactId>
<version>2.0.0</version>
</dependency>
Java module name: org.joda.money
.