Java Format BigDecimal with Comma and Dot

tanut aran
Sep 8, 2024

--

It is common to format BigDecimal to the accounting format like below

10000.02 --> 10,000.02

21231231.11 --> 21,231,231.11

Just like double or other format, we can use DecimalFormat with #,###.##

DecimalFormat decimalFormat = new DecimalFormat("#,###.##");

decimalFormat.format(theNumber)

decimalFormat.format(anotherNumber)

--

--

tanut aran
tanut aran

Written by tanut aran

Co-founder and Coder at work !

Responses (1)