You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private static final MoneyAmountStyle MONEY_AMOUNT_STYLE =
MoneyAmountStyle.ASCII_DECIMAL_POINT_GROUP3_COMMA.withGroupingStyle(GroupingStyle.BEFORE_DECIMAL_POINT);
private static final MoneyFormatter FORMATTER = new MoneyFormatterBuilder().appendAmount(MONEY_AMOUNT_STYLE).toFormatter();
Because if I use:
private static final MoneyFormatter FORMATTER = new MoneyFormatterBuilder().appendAmount().toFormatter();
Money with 3 decimals like BHD are printed like:
final String result=FORMATTER.print(BigMoney.of(CurrencyUnit.getInstance("BHD"), 6345345.7345345d).toMoney(RoundingMode.HALF_EVEN));
And the result is "6,345,345.735," with one final coma innecesary.
This problem is solved using 1) but in this case money with no decimals like JPY money print wrong:
String result =FORMATTER.print( BigMoney.of(CurrencyUnit.JPY, 12d).toMoney(RoundingMode.HALF_EVEN));
The result is 1212
Allways repeat the number because in AmountPrinterParser Java class in print method lines 66 and 67:
final int decPoint = str.indexOf('.'); --> This is -1 when not found.
final int afterDecPoint = decPoint + 1;; --> And this is 0 for not decimals values.
Then in line 92 of same class:
if (activeStyle.getGroupingStyle() == GroupingStyle.BEFORE_DECIMAL_POINT) {
appendable.append(str.substring(afterDecPoint));
}
And append all the number again because str.substring(0) = str
with result 1212.
Thanks.
The text was updated successfully, but these errors were encountered:
Hello,
I'm using:
1)
Because if I use:
Money with 3 decimals like BHD are printed like:
And the result is "6,345,345.735," with one final coma innecesary.
This problem is solved using 1) but in this case money with no decimals like JPY money print wrong:
The result is 1212
Allways repeat the number because in AmountPrinterParser Java class in print method lines 66 and 67:
Then in line 92 of same class:
And append all the number again because str.substring(0) = str
with result 1212.
Thanks.
The text was updated successfully, but these errors were encountered: