cmichael
cmichael

Reputation: 11

decimalformat versus string.format

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

Upvotes: 1

Views: 2434

Answers (3)

user268396
user268396

Reputation: 11996

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.

Upvotes: 0

user500074
user500074

Reputation:

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

Upvotes: 1

Stan Kurilin
Stan Kurilin

Reputation: 15792

Using decimalformat is preferable as it have Locale and other stuff

Upvotes: 1

Related Questions