在 Java 中获取所有可用的货币代码和名称

x33g5p2x  于9个月前 转载在 Java  
字(16.7k)|赞(0)|评价(0)|浏览(91)

在 Java 中,getAvailableCurrencies()Currency 类的一个静态方法,它返回所有可用的货币。 Currency 类位于 java.util 包内,getDisplayName() 方法返回货币名称。

1. 方法签名

/**
* @return the set of available currencies.  If there is no currency
* available in the runtime, the returned set is empty.
* @since 1.7
*/
 public static Set<Currency> getAvailableCurrencies()
 
 
/**
* @return the display name of this currency for the default locale
* @since 1.7
*/
public String getDisplayName()

让我们看看完整的例子。

AllCurrency.java

package org.websparrow;

import java.util.Currency;
import java.util.Set;

public class AllCurrency {
	public static void main(String[] args) {

		Set<Currency> currencies = Currency.getAvailableCurrencies();

		System.out.println("Total available currencies: " + currencies.size());
		
		for (Currency currency : currencies) {

			System.out.println("Currency Code: " + currency 
					+ ", Currency Numeric Code: " + currency.getNumericCode()
					+ ", Currency Name: " + currency.getDisplayName());
		}
	}
}

控制台日志

Total available currencies: 228
Currency Code: SRD, Currency Numeric Code: 968, Currency Name: Surinamese Dollar
Currency Code: SSP, Currency Numeric Code: 728, Currency Name: South Sudanese Pound
Currency Code: PGK, Currency Numeric Code: 598, Currency Name: Papua New Guinean Kina
Currency Code: SBD, Currency Numeric Code: 90, Currency Name: Solomon Islands Dollar
Currency Code: MXN, Currency Numeric Code: 484, Currency Name: Mexican Peso
Currency Code: NPR, Currency Numeric Code: 524, Currency Name: Nepalese Rupee
Currency Code: XBD, Currency Numeric Code: 958, Currency Name: European Unit of Account (XBD)
Currency Code: SEK, Currency Numeric Code: 752, Currency Name: Swedish Krona
Currency Code: PTE, Currency Numeric Code: 620, Currency Name: Portuguese Escudo
Currency Code: THB, Currency Numeric Code: 764, Currency Name: Thai Baht
Currency Code: HUF, Currency Numeric Code: 348, Currency Name: Hungarian Forint
Currency Code: MGA, Currency Numeric Code: 969, Currency Name: Malagasy Ariary
Currency Code: XPF, Currency Numeric Code: 953, Currency Name: CFP Franc
Currency Code: MYR, Currency Numeric Code: 458, Currency Name: Malaysian Ringgit
Currency Code: AUD, Currency Numeric Code: 36, Currency Name: Australian Dollar
Currency Code: SYP, Currency Numeric Code: 760, Currency Name: Syrian Pound
Currency Code: LAK, Currency Numeric Code: 418, Currency Name: Laotian Kip
Currency Code: NAD, Currency Numeric Code: 516, Currency Name: Namibian Dollar
Currency Code: XBC, Currency Numeric Code: 957, Currency Name: European Unit of Account (XBC)
Currency Code: HTG, Currency Numeric Code: 332, Currency Name: Haitian Gourde
Currency Code: KRW, Currency Numeric Code: 410, Currency Name: South Korean Won
Currency Code: BGN, Currency Numeric Code: 975, Currency Name: Bulgarian Lev
Currency Code: SRG, Currency Numeric Code: 740, Currency Name: Surinamese Guilder
Currency Code: LBP, Currency Numeric Code: 422, Currency Name: Lebanese Pound
Currency Code: BYR, Currency Numeric Code: 974, Currency Name: Belarusian Rouble (2000–2016)
Currency Code: LRD, Currency Numeric Code: 430, Currency Name: Liberian Dollar
Currency Code: IRR, Currency Numeric Code: 364, Currency Name: Iranian Rial
Currency Code: AED, Currency Numeric Code: 784, Currency Name: United Arab Emirates Dirham
Currency Code: BTN, Currency Numeric Code: 64, Currency Name: Bhutanese Ngultrum
Currency Code: SIT, Currency Numeric Code: 705, Currency Name: Slovenian Tolar
Currency Code: BYB, Currency Numeric Code: 112, Currency Name: Belarusian New Rouble (1994–1999)
Currency Code: TOP, Currency Numeric Code: 776, Currency Name: Tongan Pa?anga
Currency Code: ETB, Currency Numeric Code: 230, Currency Name: Ethiopian Birr
Currency Code: SLL, Currency Numeric Code: 694, Currency Name: Sierra Leonean Leone
Currency Code: DJF, Currency Numeric Code: 262, Currency Name: Djiboutian Franc
Currency Code: PKR, Currency Numeric Code: 586, Currency Name: Pakistani Rupee
Currency Code: NGN, Currency Numeric Code: 566, Currency Name: Nigerian Naira
Currency Code: IEP, Currency Numeric Code: 372, Currency Name: Irish Pound
Currency Code: MTL, Currency Numeric Code: 470, Currency Name: Maltese Lira
Currency Code: VES, Currency Numeric Code: 928, Currency Name: Venezuelan Bolívar Soberano
Currency Code: IDR, Currency Numeric Code: 360, Currency Name: Indonesian Rupiah
Currency Code: TJS, Currency Numeric Code: 972, Currency Name: Tajikistani Somoni
Currency Code: SHP, Currency Numeric Code: 654, Currency Name: St. Helena Pound
Currency Code: IQD, Currency Numeric Code: 368, Currency Name: Iraqi Dinar
Currency Code: VND, Currency Numeric Code: 704, Currency Name: Vietnamese Dong
Currency Code: MAD, Currency Numeric Code: 504, Currency Name: Moroccan Dirham
Currency Code: GNF, Currency Numeric Code: 324, Currency Name: Guinean Franc
Currency Code: GWP, Currency Numeric Code: 624, Currency Name: Guinea-Bissau Peso
Currency Code: MGF, Currency Numeric Code: 450, Currency Name: Malagasy Franc
Currency Code: ITL, Currency Numeric Code: 380, Currency Name: Italian Lira
Currency Code: RON, Currency Numeric Code: 946, Currency Name: Romanian Leu
Currency Code: MDL, Currency Numeric Code: 498, Currency Name: Moldovan Leu
Currency Code: ZMK, Currency Numeric Code: 894, Currency Name: Zambian Kwacha (1968–2012)
Currency Code: PYG, Currency Numeric Code: 600, Currency Name: Paraguayan Guarani
Currency Code: BBD, Currency Numeric Code: 52, Currency Name: Barbadian Dollar
Currency Code: MWK, Currency Numeric Code: 454, Currency Name: Malawian Kwacha
Currency Code: SDG, Currency Numeric Code: 938, Currency Name: Sudanese Pound
Currency Code: KPW, Currency Numeric Code: 408, Currency Name: North Korean Won
Currency Code: ZMW, Currency Numeric Code: 967, Currency Name: Zambian Kwacha
Currency Code: MKD, Currency Numeric Code: 807, Currency Name: Macedonian Denar
Currency Code: ARS, Currency Numeric Code: 32, Currency Name: Argentine Peso
Currency Code: INR, Currency Numeric Code: 356, Currency Name: Indian Rupee
Currency Code: MOP, Currency Numeric Code: 446, Currency Name: Macanese Pataca
Currency Code: UAH, Currency Numeric Code: 980, Currency Name: Ukrainian Hryvnia
Currency Code: TRY, Currency Numeric Code: 949, Currency Name: Turkish Lira
Currency Code: DEM, Currency Numeric Code: 276, Currency Name: German Mark
Currency Code: MNT, Currency Numeric Code: 496, Currency Name: Mongolian Tugrik
Currency Code: PAB, Currency Numeric Code: 590, Currency Name: Panamanian Balboa
Currency Code: AFA, Currency Numeric Code: 4, Currency Name: Afghan Afghani (1927–2002)
Currency Code: AZM, Currency Numeric Code: 31, Currency Name: Azerbaijani Manat (1993–2006)
Currency Code: DOP, Currency Numeric Code: 214, Currency Name: Dominican Peso
Currency Code: UZS, Currency Numeric Code: 860, Currency Name: Uzbekistani Som
Currency Code: COU, Currency Numeric Code: 970, Currency Name: Colombian Real Value Unit
Currency Code: MVR, Currency Numeric Code: 462, Currency Name: Maldivian Rufiyaa
Currency Code: EGP, Currency Numeric Code: 818, Currency Name: Egyptian Pound
Currency Code: FJD, Currency Numeric Code: 242, Currency Name: Fijian Dollar
Currency Code: BDT, Currency Numeric Code: 50, Currency Name: Bangladeshi Taka
Currency Code: NOK, Currency Numeric Code: 578, Currency Name: Norwegian Krone
Currency Code: BWP, Currency Numeric Code: 72, Currency Name: Botswanan Pula
Currency Code: KZT, Currency Numeric Code: 398, Currency Name: Kazakhstani Tenge
Currency Code: FKP, Currency Numeric Code: 238, Currency Name: Falkland Islands Pound
Currency Code: BAM, Currency Numeric Code: 977, Currency Name: Bosnia-Herzegovina Convertible Mark
Currency Code: VEF, Currency Numeric Code: 937, Currency Name: Venezuelan Bolívar
Currency Code: XAF, Currency Numeric Code: 950, Currency Name: Central African CFA Franc
Currency Code: TMM, Currency Numeric Code: 795, Currency Name: Turkmenistani Manat (1993–2009)
Currency Code: AYM, Currency Numeric Code: 945, Currency Name: AYM
Currency Code: XBB, Currency Numeric Code: 956, Currency Name: European Monetary Unit
Currency Code: KHR, Currency Numeric Code: 116, Currency Name: Cambodian Riel
Currency Code: ZWR, Currency Numeric Code: 935, Currency Name: Zimbabwean Dollar (2008)
Currency Code: XAU, Currency Numeric Code: 959, Currency Name: Gold
Currency Code: CHF, Currency Numeric Code: 756, Currency Name: Swiss Franc
Currency Code: GMD, Currency Numeric Code: 270, Currency Name: Gambian Dalasi
Currency Code: LKR, Currency Numeric Code: 144, Currency Name: Sri Lankan Rupee
Currency Code: BOV, Currency Numeric Code: 984, Currency Name: Bolivian Mvdol
Currency Code: KWD, Currency Numeric Code: 414, Currency Name: Kuwaiti Dinar
Currency Code: CYP, Currency Numeric Code: 196, Currency Name: Cypriot Pound
Currency Code: XFO, Currency Numeric Code: 0, Currency Name: French Gold Franc
Currency Code: BOB, Currency Numeric Code: 68, Currency Name: Bolivian Boliviano
Currency Code: CNY, Currency Numeric Code: 156, Currency Name: Chinese Yuan
Currency Code: PEN, Currency Numeric Code: 604, Currency Name: Peruvian Sol
Currency Code: XBA, Currency Numeric Code: 955, Currency Name: European Composite Unit
Currency Code: XDR, Currency Numeric Code: 960, Currency Name: Special Drawing Rights
Currency Code: GYD, Currency Numeric Code: 328, Currency Name: Guyanaese Dollar
Currency Code: UGX, Currency Numeric Code: 800, Currency Name: Ugandan Shilling
Currency Code: BYN, Currency Numeric Code: 933, Currency Name: Belarusian Rouble
Currency Code: ILS, Currency Numeric Code: 376, Currency Name: Israeli New Shekel
Currency Code: TND, Currency Numeric Code: 788, Currency Name: Tunisian Dinar
Currency Code: XSU, Currency Numeric Code: 994, Currency Name: Sucre
Currency Code: TMT, Currency Numeric Code: 934, Currency Name: Turkmenistani Manat
Currency Code: SKK, Currency Numeric Code: 703, Currency Name: Slovak Koruna
Currency Code: TZS, Currency Numeric Code: 834, Currency Name: Tanzanian Shilling
Currency Code: JPY, Currency Numeric Code: 392, Currency Name: Japanese Yen
Currency Code: OMR, Currency Numeric Code: 512, Currency Name: Omani Rial
Currency Code: ADP, Currency Numeric Code: 20, Currency Name: Andorran Peseta
Currency Code: XCD, Currency Numeric Code: 951, Currency Name: East Caribbean Dollar
Currency Code: GTQ, Currency Numeric Code: 320, Currency Name: Guatemalan Quetzal
Currency Code: CHW, Currency Numeric Code: 948, Currency Name: WIR Franc
Currency Code: USD, Currency Numeric Code: 840, Currency Name: US Dollar
Currency Code: HKD, Currency Numeric Code: 344, Currency Name: Hong Kong Dollar
Currency Code: BND, Currency Numeric Code: 96, Currency Name: Brunei Dollar
Currency Code: EEK, Currency Numeric Code: 233, Currency Name: Estonian Kroon
Currency Code: CUC, Currency Numeric Code: 931, Currency Name: Cuban Convertible Peso
Currency Code: KES, Currency Numeric Code: 404, Currency Name: Kenyan Shilling
Currency Code: UYU, Currency Numeric Code: 858, Currency Name: Uruguayan Peso
Currency Code: AFN, Currency Numeric Code: 971, Currency Name: Afghan Afghani
Currency Code: BZD, Currency Numeric Code: 84, Currency Name: Belize Dollar
Currency Code: KYD, Currency Numeric Code: 136, Currency Name: Cayman Islands Dollar
Currency Code: RUB, Currency Numeric Code: 643, Currency Name: Russian Rouble
Currency Code: NZD, Currency Numeric Code: 554, Currency Name: New Zealand Dollar
Currency Code: MMK, Currency Numeric Code: 104, Currency Name: Myanmar Kyat
Currency Code: AWG, Currency Numeric Code: 533, Currency Name: Aruban Florin
Currency Code: XUA, Currency Numeric Code: 965, Currency Name: ADB Unit of Account
Currency Code: BHD, Currency Numeric Code: 48, Currency Name: Bahraini Dinar
Currency Code: ISK, Currency Numeric Code: 352, Currency Name: Icelandic Króna
Currency Code: XXX, Currency Numeric Code: 999, Currency Name: Unknown Currency
Currency Code: LTL, Currency Numeric Code: 440, Currency Name: Lithuanian Litas
Currency Code: MRO, Currency Numeric Code: 478, Currency Name: Mauritanian Ouguiya (1973–2017)
Currency Code: BGL, Currency Numeric Code: 100, Currency Name: Bulgarian Hard Lev
Currency Code: TRL, Currency Numeric Code: 792, Currency Name: Turkish Lira (1922–2005)
Currency Code: HRK, Currency Numeric Code: 191, Currency Name: Croatian Kuna
Currency Code: SGD, Currency Numeric Code: 702, Currency Name: Singapore Dollar
Currency Code: ALL, Currency Numeric Code: 8, Currency Name: Albanian Lek
Currency Code: TPE, Currency Numeric Code: 626, Currency Name: Timorese Escudo
Currency Code: LSL, Currency Numeric Code: 426, Currency Name: Lesotho Loti
Currency Code: VUV, Currency Numeric Code: 548, Currency Name: Vanuatu Vatu
Currency Code: NLG, Currency Numeric Code: 528, Currency Name: Dutch Guilder
Currency Code: XFU, Currency Numeric Code: 0, Currency Name: French UIC-Franc
Currency Code: AZN, Currency Numeric Code: 944, Currency Name: Azerbaijani Manat
Currency Code: SAR, Currency Numeric Code: 682, Currency Name: Saudi Riyal
Currency Code: PHP, Currency Numeric Code: 608, Currency Name: Philippine Piso
Currency Code: ESP, Currency Numeric Code: 724, Currency Name: Spanish Peseta
Currency Code: ZAR, Currency Numeric Code: 710, Currency Name: South African Rand
Currency Code: ZWN, Currency Numeric Code: 942, Currency Name: ZWN
Currency Code: KGS, Currency Numeric Code: 417, Currency Name: Kyrgystani Som
Currency Code: FIM, Currency Numeric Code: 246, Currency Name: Finnish Markka
Currency Code: BIF, Currency Numeric Code: 108, Currency Name: Burundian Franc
Currency Code: ANG, Currency Numeric Code: 532, Currency Name: Netherlands Antillean Guilder
Currency Code: CZK, Currency Numeric Code: 203, Currency Name: Czech Koruna
Currency Code: COP, Currency Numeric Code: 170, Currency Name: Colombian Peso
Currency Code: GHS, Currency Numeric Code: 936, Currency Name: Ghanaian Cedi
Currency Code: KMF, Currency Numeric Code: 174, Currency Name: Comorian Franc
Currency Code: MZN, Currency Numeric Code: 943, Currency Name: Mozambican Metical
Currency Code: LVL, Currency Numeric Code: 428, Currency Name: Latvian Lats
Currency Code: GRD, Currency Numeric Code: 300, Currency Name: Greek Drachma
Currency Code: EUR, Currency Numeric Code: 978, Currency Name: Euro
Currency Code: BSD, Currency Numeric Code: 44, Currency Name: Bahamian Dollar
Currency Code: CUP, Currency Numeric Code: 192, Currency Name: Cuban Peso
Currency Code: RSD, Currency Numeric Code: 941, Currency Name: Serbian Dinar
Currency Code: UYI, Currency Numeric Code: 940, Currency Name: Uruguayan Peso (Indexed Units)
Currency Code: TWD, Currency Numeric Code: 901, Currency Name: New Taiwan Dollar
Currency Code: MRU, Currency Numeric Code: 929, Currency Name: Mauritanian Ouguiya
Currency Code: VEB, Currency Numeric Code: 862, Currency Name: Venezuelan Bolívar (1871–2008)
Currency Code: RUR, Currency Numeric Code: 810, Currency Name: Russian Rouble (1991–1998)
Currency Code: CVE, Currency Numeric Code: 132, Currency Name: Cape Verdean Escudo
Currency Code: CDF, Currency Numeric Code: 976, Currency Name: Congolese Franc
Currency Code: JOD, Currency Numeric Code: 400, Currency Name: Jordanian Dinar
Currency Code: CSD, Currency Numeric Code: 891, Currency Name: Serbian Dinar (2002–2006)
Currency Code: QAR, Currency Numeric Code: 634, Currency Name: Qatari Rial
Currency Code: TTD, Currency Numeric Code: 780, Currency Name: Trinidad & Tobago Dollar
Currency Code: GBP, Currency Numeric Code: 826, Currency Name: British Pound
Currency Code: USN, Currency Numeric Code: 997, Currency Name: US Dollar (Next day)
Currency Code: ERN, Currency Numeric Code: 232, Currency Name: Eritrean Nakfa
Currency Code: AMD, Currency Numeric Code: 51, Currency Name: Armenian Dram
Currency Code: CAD, Currency Numeric Code: 124, Currency Name: Canadian Dollar
Currency Code: PLN, Currency Numeric Code: 985, Currency Name: Polish Zloty
Currency Code: SOS, Currency Numeric Code: 706, Currency Name: Somali Shilling
Currency Code: CHE, Currency Numeric Code: 947, Currency Name: WIR Euro
Currency Code: ROL, Currency Numeric Code: 642, Currency Name: Romanian Leu (1952–2006)
Currency Code: JMD, Currency Numeric Code: 388, Currency Name: Jamaican Dollar
Currency Code: CLF, Currency Numeric Code: 990, Currency Name: Chilean Unit of Account (UF)
Currency Code: SVC, Currency Numeric Code: 222, Currency Name: Salvadoran Colón
Currency Code: USS, Currency Numeric Code: 998, Currency Name: US Dollar (Same day)
Currency Code: XAG, Currency Numeric Code: 961, Currency Name: Silver
Currency Code: GHC, Currency Numeric Code: 288, Currency Name: Ghanaian Cedi (1979–2007)
Currency Code: GEL, Currency Numeric Code: 981, Currency Name: Georgian Lari
Currency Code: YUM, Currency Numeric Code: 891, Currency Name: Yugoslavian New Dinar (1994–2002)
Currency Code: LUF, Currency Numeric Code: 442, Currency Name: Luxembourgian Franc
Currency Code: CLP, Currency Numeric Code: 152, Currency Name: Chilean Peso
Currency Code: ZWL, Currency Numeric Code: 932, Currency Name: Zimbabwean Dollar (2009)
Currency Code: BRL, Currency Numeric Code: 986, Currency Name: Brazilian Real
Currency Code: RWF, Currency Numeric Code: 646, Currency Name: Rwandan Franc
Currency Code: GIP, Currency Numeric Code: 292, Currency Name: Gibraltar Pound
Currency Code: MXV, Currency Numeric Code: 979, Currency Name: Mexican Investment Unit
Currency Code: SDD, Currency Numeric Code: 736, Currency Name: Sudanese Dinar (1992–2007)
Currency Code: SZL, Currency Numeric Code: 748, Currency Name: Swazi Lilangeni
Currency Code: HNL, Currency Numeric Code: 340, Currency Name: Honduran Lempira
Currency Code: NIO, Currency Numeric Code: 558, Currency Name: Nicaraguan Córdoba
Currency Code: YER, Currency Numeric Code: 886, Currency Name: Yemeni Rial
Currency Code: BMD, Currency Numeric Code: 60, Currency Name: Bermudan Dollar
Currency Code: CRC, Currency Numeric Code: 188, Currency Name: Costa Rican Colón
Currency Code: WST, Currency Numeric Code: 882, Currency Name: Samoan Tala
Currency Code: AOA, Currency Numeric Code: 973, Currency Name: Angolan Kwanza
Currency Code: SCR, Currency Numeric Code: 690, Currency Name: Seychellois Rupee
Currency Code: XTS, Currency Numeric Code: 963, Currency Name: Testing Currency Code
Currency Code: STN, Currency Numeric Code: 930, Currency Name: São Tomé & Príncipe Dobra
Currency Code: MZM, Currency Numeric Code: 508, Currency Name: Mozambican Metical (1980–2006)
Currency Code: DKK, Currency Numeric Code: 208, Currency Name: Danish Krone
Currency Code: STD, Currency Numeric Code: 678, Currency Name: São Tomé & Príncipe Dobra (1977–2017)
Currency Code: FRF, Currency Numeric Code: 250, Currency Name: French Franc
Currency Code: LYD, Currency Numeric Code: 434, Currency Name: Libyan Dinar
Currency Code: XPD, Currency Numeric Code: 964, Currency Name: Palladium
Currency Code: ZWD, Currency Numeric Code: 716, Currency Name: Zimbabwean Dollar (1980–2008)
Currency Code: XOF, Currency Numeric Code: 952, Currency Name: West African CFA Franc
Currency Code: MUR, Currency Numeric Code: 480, Currency Name: Mauritian Rupee
Currency Code: BEF, Currency Numeric Code: 56, Currency Name: Belgian Franc
Currency Code: ATS, Currency Numeric Code: 40, Currency Name: Austrian Schilling
Currency Code: DZD, Currency Numeric Code: 12, Currency Name: Algerian Dinar
Currency Code: XPT, Currency Numeric Code: 962, Currency Name: Platinum

相关文章

热门文章

更多