Good afternoon, tell me, please ... how to form and save the amount of 123.00 using BigDecimal, if you transferred it as 123?
I did not find any similar formatters, I will be grateful for the help.
Good afternoon, tell me, please ... how to form and save the amount of 123.00 using BigDecimal, if you transferred it as 123?
I did not find any similar formatters, I will be grateful for the help.
Thanks to all. Solved. For saving in the String format, the formatter is suitable:
public static String toString(BigDecimal bigDecimal) { DecimalFormat numFormat; String number; numFormat = new DecimalFormat(".00"); number = numFormat.format(bigDecimal); return number; }
new BigDecimal("123.00").setScale(2, RoundingMode.HALF_UP);
new BigDecimal("123").setScale...
- SergeySource: https://ru.stackoverflow.com/questions/541317/
All Articles