2015-01-05 34 views
1

當我使用String.format方法時,如果我的手機語言是波斯語,此方法返回波斯語言的格式化數字。但我想使用英文格式的數字。 我使用此代碼:如何通過String.format英文返回格式化數字?

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

我的問題在圖片:

enter image description here

+1

你可以改變語言環境嗎?或者我在這裏錯過了什麼? String strValue = String.format(Locale.ENGLISH,「%。02f」,myNumber); – Josh

回答

8

我認爲你需要使用String.format(Locale, String, ...)方法與英語語言環境的實例,可能與Locale.ENGLISH。這將告訴String.format使用英文數字格式而不是波斯語。

+0

@MarounMaroun應該可以。 「零位」(0代表英文,0代表波斯語)深埋在Locale中。 –

+0

這不適合我。我使用具有不同字體的自定義textView來顯示格式化的字符串。這是否有任何問題? – Nithinjith