3

一个例子将最好地解释我想要什么 - 可以说,我有一个这样的数字34236536465.57。我想这样格式化它:34,23,65,36,465.57. 除了手动操作之外,我可以使用任何 JDK 类或第三方库吗?我已经尝试过java.text.DecimalFormat("#,##,###.##"),但是逗号仅在 3 位数字之后出现,而我希望逗号在 3 位数字之后出现,然后在 2 位数字之后出现。

4

1 回答 1

1

com.ibm.icu.text.DecimalFormat class of ICU4J library can exactly do the same thing. And we can use the same pattern "#,##,###.##" as it is used in java.text.DecimalFormat to format the way exactly I wanted.

于 2013-03-20T04:39:52.670 回答