我想要给一个类型为
例如,对于值1234.5:
double
的变量添加千位分隔符。我尝试使用String.format("%,f", x);
等方法,但似乎它有固定的小数位数,不像Double.toString()
。例如,对于值1234.5:
Double.toString()
:1234.5
String.format()
:1.234,500000
期望结果:1.234,5
NumberFormat
并不完美,但它的一个子类DecimalFormat
却可以。 - dsfsdfsdfNumberFormat.getInstance()
中指定区域设置。 - Marco Sulla