以下代码用于格式化正确货币的数字:
public static String getFormattedCurrency(String currencyCode, String currencyName, Number value) {
//....
NumberFormat format = NumberFormat.getCurrencyInstance(Locale.getDefault());
Currency currency = Currency.getInstance(currencyCode);
format.setCurrency(currency);
if (format instanceof DecimalFormat) {
format.setMinimumFractionDigits(CURRENCY_MIN_FRACTION_DIGITS);
}
Log.d("Currency", "Symbol: " + currency.getSymbol() + ", Currency: " + currency + ", Locale: " + local);
return format.format(value);
}
currencyCode
的价值是THB
,即泰铢。在棒棒糖上,currency.getSymbol()
返回฿
,即泰铢的标志。但是,在Oreo上,相同的方法返回THB
。
为什么在这两个API级别之间返回不同的值?