java add commas to numbers

Solutions on MaxInterview for java add commas to numbers by the best coders in the world

showing results for - "java add commas to numbers"
Hugh
02 May 2018
1String number = "1000500000.574";
2double amount = Double.parseDouble(number);
3DecimalFormat formatter = new DecimalFormat("#,###.00");
4// the zeroes after the point are the number of digits shown after the period
5// you can also switch point and commas and get for example 1.002,45
6System.out.println(formatter.format(amount));
7// this prints 1,000,500,000.57