I understand that BigDecimal is recommended best practice for representing monetary values in Java. What do you use? Is there a better library that you prefer to use instead?
I understand that BigDecimal is recommended best practice for representing monetary values in Java.
Share
BigDecimalall the way. I’ve heard of some folks creating their ownCashorMoneyclasses which encapsulate a cash value with the currency, but under the skin it’s still aBigDecimal, probably withBigDecimal.ROUND_HALF_EVENrounding.Edit: As Don mentions in his answer, there are open sourced projects like timeandmoney, and whilst I applaud them for trying to prevent developers from having to reinvent the wheel, I just don’t have enough confidence in a pre-alpha library to use it in a production environment. Besides, if you dig around under the hood, you’ll see they use
BigDecimaltoo.