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

Java example source code file (index.md)

This example Java source code file (index.md) is included in the alvinalexander.com "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 index.md 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](https://github.com/JodaOrg/joda-money) 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:

<pre>
  // 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 = money.plus(Money.of(usd, 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();
</pre>


---

## <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](http://www.joda.org/joda-convert/),
but this is not required at runtime thanks to the magic of annotations.

Available in [Maven Central](http://search.maven.org/#artifactdetails%7Corg.joda%7Cjoda-money%7C0.11%7Cjar).

```xml
<dependency>
  <groupId>org.joda
  <artifactId>joda-money
  <version>0.11
</dependency>
```

---

### 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](https://github.com/JodaOrg/joda-money)
on GitHub and send a Pull Request.

Alternatively, use GitHub [issues](https://github.com/JodaOrg/joda-money/issues).

Other Java examples (source code examples)

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



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
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.