2

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?

zella
  • 4,645
  • 6
  • 35
  • 60
  • As long as the computation for currency conversion is correct, you might get an extraneously long float, but is there a reason you can't just round it yourself? – awiebe Feb 01 '17 at 07:02

1 Answers1

0

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.

Werner Keil
  • 592
  • 5
  • 12