如何在Java/Kotlin中获取NumberFormat的区域设置?

如何在Java/Kotlin中获取NumberFormat的区域设置?,java,kotlin,locale,number-formatting,Java,Kotlin,Locale,Number Formatting,根据,NumberFormat.getInstance将为您获取当前区域设置中的NumberFormat实例。在创建实例之后,我想验证一下使用getLocale这样的方法的区域设置是什么,但是那里似乎没有记录这样的方法 要确定这一点,我只能在Kotlin shell kotlinc中调用Locale.getDefault: >>>导入java.math.BigDecimal >>>导入java.text.NumberFormat >>>NumberFormat.getInstance.forma

根据,NumberFormat.getInstance将为您获取当前区域设置中的NumberFormat实例。在创建实例之后,我想验证一下使用getLocale这样的方法的区域设置是什么,但是那里似乎没有记录这样的方法

要确定这一点,我只能在Kotlin shell kotlinc中调用Locale.getDefault:

>>>导入java.math.BigDecimal >>>导入java.text.NumberFormat >>>NumberFormat.getInstance.formatBigDecimal1500 1,500 >>>导入java.util.Locale >>>Locale.getDefault 恩努斯 是否没有NumberFormat.getLocale方法

是否没有NumberFormat.getLocale方法

没有-您可以做的是调用NumberFormat.getInstance在引擎盖下执行的相同方法:

Locale defaultLocale = Locale.getDefault(Locale.Category.FORMAT);
Java 8中有两个类别:。如果您需要显示一个,只需交换参数