Sunday, 27 December 2015

Corrency symbol for all country

Code to get currency symbol:

    Currency currency = null;
    Locale locale = null;
    String currencySymbol = null;
  /*Get List of available countries from liferay country table*/
    List<Country> countryCode = CountryServiceUtil.getCountries();
   
    for(Country country:countryCode)
    {
        try{
            locale = new Locale.Builder().setRegion(country.getA2()).build();
            currency = Currency.getInstance(locale);   
               currencySymbol = currency.getSymbol(locale);
              System.out.println("currency symbol is......"+currencySymbol);}
        catch(Exception e){
            System.out.println("exception..."+e);
        }
    }

No comments:

Post a Comment