Search code examples
javaandroidcurrency

getSymbol() in java.util.Currency returns different values depending on API level


The following code is being used to format a number in the proper currency:

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);
}

The value of currencyCode is THB, the Thai baht. On Lollipop, currency.getSymbol() returns ฿, the sign for the Thai baht. However, on Oreo, the same method returns THB.

Why are different values being returned between these two API levels?


Solution

  • Based on this issue, it would appear to be a Unicode decision.