📜  java 给数字添加逗号 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:49.597000             🧑  作者: Mango

代码示例1
String number = "1000500000.574";
double amount = Double.parseDouble(number);
DecimalFormat formatter = new DecimalFormat("#,###.00");
// the zeroes after the point are the number of digits shown after the period
// you can also switch point and commas and get for example 1.002,45
System.out.println(formatter.format(amount));
// this prints 1,000,500,000.57