在 Java 中将双精度格式 10000.00 转换为 10,000.00

Convert Double Format 10000.00 to 10,000.00 in Java

我对 Java 很陌生。

知道如何将 double 变量中的 10000 格式转换为 10,000.00 吗?

感谢您的关注。

您可以尝试这样的操作。

double d=10000;
NumberFormat formatter = new DecimalFormat("#0,000.00");
System.out.println(formatter.format(d));

输出

10,000.00

给你

DecimalFormat myFormatter = new DecimalFormat("###,###.00");
String output = myFormatter.format(value);
System.out.println(value + " " + pattern + " " + output);

查看this了解更多信息

检查此 tutorial, 这绝对绰绰有余。在您的情况下,格式为 #,###.00

DecimalFormat decimalFormat = new DecimalFormat("#,###.00");
System.out.println(decimalFormat.format(10000));