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.
精彩评论