java - 如何通过英文的 String.format 返回格式化的数字?

标签 java android string-formatting non-english

当我使用 String.format 方法时,如果我的电话语言是波斯语,则此方法返回波斯语格式的数字。但我想使用英文格式的数字。 我使用这段代码:

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

图中我的问题:

enter image description here

最佳答案

我认为您需要使用 String.format(Locale, String, ...)带有英语 Locale 实例的方法,可能带有 Locale.ENGLISH。这将告诉 String.format 使用英文数字格式而不是波斯语。

关于java - 如何通过英文的 String.format 返回格式化的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27788563/

相关文章:

android - 展开 View 后匹配父级宽度

android - 更改字段文本的 PDFbox 字体

c# - 如何在C#中使用 “0”验证数字的输入项是否不是

c - 如何控制程序输出的格式?

Java 正则表达式与 src ="abc"或 src ='abc' 匹配

java - getParseFile(string key) 使用扩展的 ParseObject 类从 Parse.com 返回 null

java - 为什么我的面板不抽牌?

java - 查询所有Google App Engine

android - 在 Eclipse : no repository found 中安装 ADT 时出错

Python 3.5 字符串格式 : How to add a thousands-separator and also right justify?