开发者

decimalformat versus string.format

With string.format introduced in Java 5, is decimalformat now obsolete? I'm having a hard time开发者_JAVA技巧 finding something you can do in decimalformat that you can't do in string.format.


Using decimalformat is preferable as it have Locale and other stuff


String.format is a static method call but you can create a DecimalFormat instance and reuse a previously specified format.


There is some stuff like automatic promilles and currency symbol substitution. But it is nothing that you can't do better with proper localisation of your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜