| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (

This example Java source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

apache, api, bigmoney, currencyunit, github, jdk, joda-money, money, request, support, the, there, this, usd

The Java example source code

## <i> 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](license.html).

## <i> Features

A selection of key features:

* `CurrencyUnit` - representing a currency
* `Money` - a fixed precision monetary value type
* `BigMoney` - a variable precision monetary type
* A customizable formatter

## <i> Documentation

Various documentation is available:

* The helpful [user guide](userguide.html)
* The [Javadoc](apidocs/index.html)
* The [change notes](changes-report.html) for each release
* The [GitHub]( source repository


## <i> 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
  <b>Money money = Money.parse("USD 23.87");
  // add another amount with safe double conversion
  <b>CurrencyUnit usd = CurrencyUnit.of("USD");
  <b>money =, 12.43d));
  // subtracts an amount in dollars
  <b>money = money.minusMajor(2);
  // multiplies by 3.5 with rounding
  <b>money = money.multipliedBy(3.5d, RoundingMode.DOWN);
  // compare two amounts
  <b>boolean bigAmount = money.isGreaterThan(dailyWage);
  // convert to GBP using a supplied rate
  <b>BigDecimal conversionRate = ...;  // obtained from code outside Joda-Money
  <b>Money moneyGBP = money.convertedTo(CurrencyUnit.GBP, conversionRate, RoundingMode.HALF_UP);
  // use a BigMoney for more complex calculations where scale matters
  <b>BigMoney moneyCalc = money.toBigMoney();


## <i> Releases

There are no full releases yet!
[Release 0.11](download.html) is the current development release intended for feedback.
The code is fully tested, but there may yet be bugs and the API may yet change.
There should be no great reason why it cannot be used in production if you can cope with future API change.

Joda-Money requires Java SE 6 or later and has [no dependencies](dependencies.html).
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](



### Support

Support on bugs, library usage or enhancement requests is available on a best efforts basis.

To suggest enhancements or contribute, please [fork the source code](
on GitHub and send a Pull Request.

Alternatively, use GitHub [issues](

Other Java examples (source code examples)

Here is a short list of links related to this Java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.