|
The userguide.xml Java example source code
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<properties>
<title>User guide
<author>Stephen Colebourne
</properties>
<body>
<section name="User guide">
<p>
Joda-Money is a small Java library providing classes to store, format and parse amounts of money.
This is a brief user guide to the features available.
</p>
</section>
<section name="Main classes">
<p>
There are two main classes which are both based on <code>BigDecimal:
<ul>
<li>Money - an amount in a single currency where the decimal places is determined by the currency
<li>BigMoney - an amount in a single currency where there is no restriction on the scale
</ul>
</p>
<p>
For example, the currencies of US dollars, Euros and British Pounds all use 2 decimal places,
thus a <code>Money instance for any of these currencies will have 2 decimal places.
By contrast, the Japanese Yen has 0 decimal places, and thus any <code>Money instance with that
currency will have 0 decimal places.
</p>
<p>
Instances of <code>BigMoney may have a scale that is positive or zero.
Negative scales are normalized to zero.
</p>
<p>
Conversion between a <code>Money and a BigMoney can be performed using the methods
<code>toBigMoney() and toMoney() . The latter optionally takes a rounding mode to
handle the case where information must be lost.
</p>
<p>
Both classes implement the <code>BigMoneyProvider interface.
This allows many different classes, including user supplied classes, to interoperate with Joda-Money.
In application code, the best advice is to use the concrete types.
However, utility and framework code will typically use the interface.
The formatting code is a good example of this.
</p>
</section>
<section name="Currency information">
<p>
Joda-Money includes its own currency class as the implementation in the JDK is too restrictive.
The data for the Joda-Money class is provided by two configuration files.
</p>
<p>
The file <code>org/joda/money/MoneyData.csv holds a basic list of valid currencies.
The columns are as follows:
<ul>
<li>ISO-4217 currency code - three letters, mandatory
<li>ISO-4217 numeric code - from 1 to 999, set to -1 if no numeric code
<li>Number of decimal places in common usage - the supplied data is based on various sources
<li>Country codes - a list of ISO-3166-1country codes,
adjacent to one another and without separators</li>
</ul>
</p>
<p>
The library will load the first version of this file it finds in the classpath based on the
class loader that Joda-Money is loaded in.
</p>
<p>
The file <code>org/joda/money/MoneyDataExtension.csv holds any user extensions to the currency list.
It has the same file format as above.
This file is optional and not supplied by default.
Again, the first instance of the file on the classpath will be loaded.
</p>
</section>
<section name="Formatting">
<p>
Formatting is based around the <code>MoneyFormatterBuilder class.
The builder is used to create a suitable format which is then converted to an immutable <code>MoneyFormatter instance.
The format may contain localized aspects which can be use by calling <code>withLocale() on the formatter.
This returns a new formatter as it is immutable.
</p>
<p>
The symbol information for formatting is currently provided by the JDK.
</p>
<p>
<br />
</p>
<p>
<br />
</p>
</section>
</body>
</document>
Other Java examples (source code examples)
Here is a short list of links related to this Java userguide.xml source code file:
|