Sunday 23 August 2009

Joda-Money

I've been busy piloting a new open source project - Joda-Money. The idea is a simple money and currency package along the lines of Joda-Time.

Joda-Money

Joda-Money is a new project to try and create a small, focussed monetary library for Java. While there are various libraries that tackle this area, I wanted one that fitted with the Joda-Time style.

So far, I've created a Money and CurrencyUnit class and started on formatting. The goal of the library is only these basic classes. Financial calculations (for whatever domain) or classes storing specific concepts like gross/net/tax are out of scope for the library.

The design is as follows:

Money is the main class, and supports an amount of money with the decimal places determined by the currency. Thus, GBP always has 2 decimal places, while JPY always has 0.

CurrencyUnit is the class representing currency. I debated whether to just use the JDK Currency class, but it doesn't handle currency changes, or provide the numeric code (both being fixed in JDK 7).

MoneyFormatter will provide formatting of Money instances.

BigMoney will be the final class, which will allow any amount of decimal places to be specified for any currency.

This blog is a 'release early' notification. If you like the Javadoc, or think that this is an area that should be tackled, then let me know. If not, then also let me know (I don't want to waste my time...). Lets hear the feedback!