Reputation: 1
String.format("%.2f",0.333333);
gives 0,33
but I'd like to have 0.33
.
Upvotes: 0
Views: 257
Reputation: 1420
String.format()
picks the locale you are in. You have to specify the locale explicitly if you want. instead of,
You can use it like this:
String.format(Locale.US, "%.2f", 0.333333)
Upvotes: 0
Reputation: 11
Put Locale.ROOT inside, like this:
String.format(Locale.ROOT, "%.2f",0.333333);
Upvotes: 1