java String.format:具有本地化的数字 [英] java String.format: numbers with localization
本文介绍了java String.format:具有本地化的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以像NumberFormat.format一样以String.format调用来本地化数字?
Is it possible to localize numbers in String.format call the same way as NumberFormat.format does?
我期望它只是使用
String.format(locale, "%d", number)
,但这不会返回与使用NumberFormat相同的结果.例如:
but this doesn't return the same result as if using NumberFormat. For example:
String.format(Locale.GERMAN, "%d", 1234567890)
给出:"1234567890",而
gives: "1234567890", while
NumberFormat.getNumberInstance(Locale.GERMAN).format(1234567890)
给出:"1.234.567.890"
gives: "1.234.567.890"
如果无法完成,建议对包含数字的文本进行本地化的推荐方式是什么?
If it can't be done, what's recommended way for localizing text including numbers?
推荐答案
查看全文