Get the currency symbol based on country

后端 未结 2 1109
情深已故
情深已故 2021-01-13 15:05

I have a TextView which display currencies. By default my textview\'s text is: $0.00 How can I make it so the $ changes based on user selection.

相关标签:
2条回答
  • 2021-01-13 15:22

    You could use a regular expression to remove all word characters.

        String symbol = currency.getSymbol().replaceAll("\\w", "");
    

    However this may not be ideal if any of the monetary symbols you are dealing with use letters.

    0 讨论(0)
  • 2021-01-13 15:44

    If what you want is to add that format to a number you have you could do

    myString = NumberFormat.getCurrencyInstance().format(myNumber);
    

    for default or

    myString = NumberFormat.getCurrencyInstance(new Locale("en", "AU")).format(myNumber);
    

    for specified

    0 讨论(0)
提交回复
热议问题