📅  最后修改于: 2020-11-15 03:36:50             🧑  作者: Mango
在此示例中,我们将根据美国语言环境和丹麦语言环境来设置货币格式。
IOTester.java
import java.text.NumberFormat;
import java.util.Locale;
public class I18NTester {
public static void main(String[] args) {
Locale enLocale = new Locale("en", "US");
Locale daLocale = new Locale("da", "DK");
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(daLocale);
System.out.println(numberFormat.format(100.76));
numberFormat = NumberFormat.getCurrencyInstance(enLocale);
System.out.println(numberFormat.format(100.76));
}
}
它将打印以下结果。
kr 100,76
$100.76