In a comment on my other answer, Gary Rowe has suggested the use of Joda Money as a solution.
Now while this may be a fine product, and I have to admit that I have not tried it, I am a bit concerned about the following example in their documentation:
// multiplies by 3.5 with rounding
money = money.multipliedBy(3.5d, RoundingMode.DOWN);
Now this is an interesting example because they have used a double amount which can be represented exactly using double precision.
To illustrate this, let's take the following unit test as an example:
double d1 = 3.5d;
BigDecimal bd1 = new BigDecimal(d1);
System.out.println("BD version of " + d1 + " = " + bd1);
BigDecimal bd2 = new BigDecimal("10000000");
BigDecimal bd3 = bd2.multiply(bd1);
System.out.println("Result in bd3 = " + bd3);
This yields the following output:
BD version of 3.5 = 3.5
Result in bd3 = 35000000.0
However, if you change the '3.5d' to '3.4d', you get a very different result:
BD version of 3.4 = 3.399999999999999911182158029987476766109466552734375
Result in bd3 = 33999999.999999999111821580299874767661094665527343750000000
Now the Joda Money classes may deal with this (somehow), but introducing any double precision numbers into the mix is fraught with danger.
Gary, perhaps you could comment about the result of a similar calculation in Joda Money.