To return the currency symbols for any Currency we can create a global function that will take as parameter the currency code.

So the function will take, for example, the code USD and return $.

Create a Global Function with the flowing parameters:

Function Name: getCurrencySymbol

Returns: String

Parameters

Name: CurrencyCode  ; Type: String

def map = [:];  
for (Locale locale : Locale.getAvailableLocales()) {  
try {  
Currency currency = Currency.getInstance(locale);  
map.put(currency, locale);    
}  
catch (Exception e){   
// no need to handle exception           
}  
}  
Currency currency = Currency.getInstance(CurrencyCode);  
String country = map.get(currency);  
String country1 = country.substring(country.lastIndexOf(“_”) + 1);  
Locale locale = new Locale(“EN”,country1);  
Currency currency1 = Currency.getInstance(locale);  
String symbol = currency1.getSymbol(map.get(currency));  
  
return symbol  

And this function can be used in code by calling it as below:

adf.util.getCurrencySymbol(java.lang.String)  

 

Leave a Reply

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