开发者

decimalformat versus string.format

开发者 https://www.devze.com 2023-01-28 19:04 出处:网络
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 de

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

精彩评论

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