久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

沒有獲取特定語言環(huán)境的貨幣符號

Not getting currency symbols for specific Locale(沒有獲取特定語言環(huán)境的貨幣符號)
本文介紹了沒有獲取特定語言環(huán)境的貨幣符號的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試根據(jù)語言環(huán)境獲取貨幣符號.但不是返回符號,而是返回代碼.我有一個片段:

I am trying to get the symbols of the currencies based on their Locale. But instead of returning a symbol, it is returning the code. I have a snippet:

import java.util.Currency;
import java.util.Locale;

public class CurrencyFormat
{
  public void displayCurrencySymbols() 
  {
   Currency currency = Currency.getInstance(Locale.US); 
   System.out.println("United States: " + currency.getSymbol());
  } 
  public static void main(String[] args)
  {
    new CurrencyFormat().displayCurrencySymbols();
  }
}

對于 Locale.US 它給出符號 $ 但如果我替換

For Locale.US it is giving symbol $ but If I replace

Currency currency = Currency.getInstance(Locale.US); 

Currency currency = Currency.getInstance(Locale.GERMANY); 

然后它不是符號,而是給出國家代碼.為什么會這樣以及我們?nèi)绾潍@得符號?

Then instead of symbol it is giving the country code. Why is this and how we can get the symbols?

在查看了一些答案后,我想明確設(shè)置一些特定的默認本地不是解決方案,因為我需要一次顯示所有可用的標志.

EDIT : After looking some answer I would like to clear that setting some specific default local is not a solution as I need all the avalaible sign displayed at once.

例如

 Locale.setDefault(Locale.UK); 

會給我歐元符號,但對于doller,它將給出代碼而不是doller符號($).

will give me the euro sign but for doller it will give the code instead of doller sign($).

推薦答案

你好,請嘗試以下代碼

import java.text.NumberFormat;
import java.util.Comparator;
import java.util.Currency;
import java.util.Locale;
import java.util.SortedMap;
import java.util.TreeMap;

public class CurrencyExample
{
    public static void main(String[] args) 
    {
         Utils.getCurrencySymbol( Currency.getInstance(Locale.US).getCurrencyCode());
         Utils.getCurrencySymbol(Currency.getInstance(Locale.JAPAN).getCurrencyCode());
         Utils.getCurrencySymbol(Currency.getInstance(Locale.UK).getCurrencyCode());
         Utils.getCurrencySymbol("INR");
    }
}

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

上面程序的輸出是這樣的:

The output of above program is like that:

USD:-$
JPY:-¥
GBP:-£
INR:-Rs.

這篇關(guān)于沒有獲取特定語言環(huán)境的貨幣符號的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 中文字幕av在线 | 免费99精品国产自在在线 | 久久久精品国产 | 在线视频日韩 | 一区二区三区四区在线视频 | 亚洲一区二区三区在线播放 | 欧美中文字幕 | 成人av播放 | 伊人91在线 | 日本一区二区不卡 | 久久er99热精品一区二区 | 玖草资源| 日韩欧美久久精品 | 成人av网站在线观看 | 国产在线播放一区二区三区 | 日本精品视频 | 午夜一区二区三区在线观看 | 国产精品国产亚洲精品看不卡15 | 狠狠色综合欧美激情 | 国产成人短视频在线观看 | 91精品久久久久久久99 | 1204国产成人精品视频 | 国产美女精品 | 福利视频1000 | 欧美乱做爰xxxⅹ久久久 | 日韩电影一区二区三区 | 国产美女一区 | 国产精品久久一区二区三区 | 日韩精品激情 | 欧美一区二区免费在线 | 国产高清精品在线 | 成人激情视频网 | 午夜色婷婷 | 福利视频一区二区 | 91黄色片免费看 | av在线播放不卡 | 国产精品日本一区二区在线播放 | 黄色免费在线观看网址 | 欧美精品一区二区三区在线 | 久久国产麻豆 | 国产精品久久久久久久久久妇女 |