How to support currency

Many applications deal with currency and it is frequently an integral component of business applications. There are many issues that complicate the representation and use of currency values such as precision and accuracy. In addition, there are differences between how currency types such as rubles and the yen are displayed. In this recipe, we will examine the data types we can use to represent currency and locale-specific issues regarding currency.

Getting ready

There are several potential data types that can be used for representing currency including:

  • Floating point numbers
  • Integer
  • BigDecimal

To determine which is best we need to consider issues such as precision and accuracy. Ease of use is another concern since we will need ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.