相关疑难解决方法(0)

如果我们在数据库中只有国家代码,则获取货币代码

我有问题获得国家货币,我通过这些代码在数据库中有国家代码我必须在java中获取国家代码我如何为此制作代码请建议我.我试着用这个例子,但它不起作用.

    class Utils {
    public static SortedMap<Currency, Locale> currencyLocaleMap;
    static {
        currencyLocaleMap = new TreeMap<Currency, Locale>(
                new Comparator<Currency>() {
                    public int compare(Currency c1, Currency c2) {
                        return c1.getCurrencyCode().compareTo(
                                c2.getCurrencyCode());
                    }
                });
        for (Locale locale : Locale.getAvailableLocales()) {
            try {
                Currency currency = Currency.getInstance(locale);
                currencyLocaleMap.put(currency, locale);
            } catch (Exception e) {
            }
        }
    }

    public static String getCurrencySymbol(String currencyCode) {
        Currency currency = Currency.getInstance(currencyCode);
        System.out.println(currencyCode + ":-"
                + currency.getSymbol(currencyLocaleMap.get(currency)));
        return currency.getSymbol(currencyLocaleMap.get(currency));
    }
}

  public class GetCurrency {
    public static void main(String[] …
Run Code Online (Sandbox Code Playgroud)

java android currency

5
推荐指数
2
解决办法
9616
查看次数

在Android中获取货币符号的正确方法是什么?

此代码工作正常,但如果我更改我的设备语言,这也会显示 Rs 那么获取货币符号的正确方法是什么?

public void displayTotlaPrice() {
    TextView totalPriceTextView = (TextView) findViewById(R.id.total_Price);
    totalPriceTextView.setText("Rs" + displayCalculatePrice());
}
Run Code Online (Sandbox Code Playgroud)

java android

3
推荐指数
1
解决办法
5876
查看次数

标签 统计

android ×2

java ×2

currency ×1