Locale Currency Symbol

后端 未结 3 634
失恋的感觉
失恋的感觉 2020-12-14 22:38

I having some problems getting the default currency symbol of the system. I am getting the currency symbol this way:

Currency currency = Currency.getInstance         


        
3条回答
  •  一整个雨季
    2020-12-14 23:19

    NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance();
        String cur = currencyFormatter.format(yourValue);
    

    This Formats your int/double to a currency based on the Device Language

        String currency = cur.replaceAll("[0-9.,]","");
    

    And this is how to get just the currency Symbol, by replacing all numbers, dots and commas

提交回复
热议问题