Search code examples
javatypescurrency

What data type to use for money in Java?


What data type should you use for money in Java?


Solution

  • Java has Currency class that represents the ISO 4217 currency codes. BigDecimal is the best type for representing currency decimal values.

    Joda Money has provided a library to represent money.