How to change roundings for MonetaryAmount division in jsr-354

753 Views Asked by At

I use jsr-354 org.javamoney.moneta api for Currency.

I need to divide money, for example I want set roundings to 0.25

So 100 dollars / 3 should be 33.25

By default

 val dollar100 = FastMoney.of(100, Monetary.getCurrency(Locale.US))  
 val res = dollar100.divide(3)

result is 33.3333

Is there a build in way to set roundings for that, or maybe other solutions?

1

There are 1 best solutions below

0
On

I don't think The JSR 354 RIs (Moneta / Moneta-BP) provide that out of the box, but you can certainly define your own MonetaryRounding for such case. If it makes sense for a large number of users, we'd be happy to consider it for JavaMoney-Lib or Shelter.