Hamidreza Samadi Hamidreza Samadi - 1 year ago 83
Java Question

how to return a formatted number by String.format in English?

When I using

method, if my phone language be Farsi this method return the formatted number in Farsi language. but I want to use an English formatted number.
I using this code:

String.format("%.02f", myNumber)

my question in picture:

enter image description here

jjm jjm
Answer Source

I think you need to use the String.format(Locale, String, ...) method with an English Locale instance, probably with Locale.ENGLISH. This will tell String.format to use English number formatting instead of Farsi.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download