Get/Find All Possible Currencies Using Java API

In this example we are generating all possible currencies using Java.


The method Locale.getAvailableLocales() returns the array of Locale values. We can iterate this array of Locale and able to view the different countries available as per the Locale.

We can also use Currency.getInstance(locale).getCurrencyCode() method to find the currency code for each country

Get/Find all possible currencies using Java

package com.test;

import java.util.Currency;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

public class FindAllCurrencyInJava {
public static void main(String[] args) {
//Find All the possible currencies using Java API
Map<String, String> currencies = new TreeMap<String, String>();
for (Locale locale : Locale.getAvailableLocales()) {
try {
currencies.put(locale.getDisplayCountry(), Currency.getInstance(locale).getCurrencyCode());
} catch (Exception e) {
// when the locale is not supported
System.out.println("Total Available currencies "+currencies);
Total Available currencies {Albania=ALL, Algeria=DZD, Argentina=ARS, Australia=AUD, Austria=EUR, Bahrain=BHD, Belarus=BYR, Belgium=EUR, Bolivia=BOB, Bosnia and Herzegovina=BAM, Brazil=BRL, Bulgaria=BGN, Canada=CAD, Chile=CLP, China=CNY, Colombia=COP, Costa Rica=CRC, Croatia=HRK, Cyprus=EUR, Czech Republic=CZK, Denmark=DKK, Dominican Republic=DOP, Ecuador=USD, Egypt=EGP, El Salvador=SVC, Estonia=EUR, Finland=EUR, France=EUR, Germany=EUR, Greece=EUR, Guatemala=GTQ, Honduras=HNL, Hong Kong=HKD, Hungary=HUF, Iceland=ISK, India=INR, Indonesia=IDR, Iraq=IQD, Ireland=EUR, Israel=ILS, Italy=EUR, Japan=JPY, Jordan=JOD, Kuwait=KWD, Latvia=LVL, Lebanon=LBP, Libya=LYD, Lithuania=LTL, Luxembourg=EUR, Macedonia=MKD, Malaysia=MYR, Malta=EUR, Mexico=MXN, Montenegro=EUR, Morocco=MAD, Netherlands=EUR, New Zealand=NZD, Nicaragua=NIO, Norway=NOK, Oman=OMR, Panama=PAB, Paraguay=PYG, Peru=PEN, Philippines=PHP, Poland=PLN, Portugal=EUR, Puerto Rico=USD, Qatar=QAR, Romania=RON, Russia=RUB, Saudi Arabia=SAR, Serbia=RSD, Serbia and Montenegro=CSD, Singapore=SGD, Slovakia=EUR, Slovenia=EUR, South Africa=ZAR, South Korea=KRW, Spain=EUR, Sudan=SDG, Sweden=SEK, Switzerland=CHF, Syria=SYP, Taiwan=TWD, Thailand=THB, Tunisia=TND, Turkey=TRY, Ukraine=UAH, United Arab Emirates=AED, United Kingdom=GBP, United States=USD, Uruguay=UYU, Venezuela=VEF, Vietnam=VND, Yemen=YER}

Your email address will not be published. Required fields are marked *