String.format(String, Object ...)正在使用JVM的默认语言环境。您可以使用
String.format(Locale,String, Object...)或
java.util.Formatter直接使用任何语言环境。
String s = String.format(Locale.US, "%.2f", price);
要么
String s = new Formatter(Locale.US).format("%.2f", price);要么
// do this at application startup, e.g. in your main() methodLocale.setDefault(Locale.US);// now you can use String.format(..) as you did beforeString s = String.format("%.2f", price);要么
// set locale using system properties at JVM startupjava -Duser.language=en -Duser.region=US ...



