Returns the symbol for this currency in the given {@code Locale}.
If the locale doesn't have any countries (e.g.
{@code Locale.JAPANESE, new Locale("en","")}), the the ISO
4217 currency code is returned.
First the locale's resource bundle is checked, if the locale has the same currency,
the CurrencySymbol in this locale bundle is returned.
Then a currency bundle for this locale is searched.
If a currency bundle for this locale does not exist, or there is no
symbol for this currency in this bundle, then the
ISO 4217 currency code is returned.
if (locale.getCountry().equals("")) { //$NON-NLS-1$
return currencyCode;
}
// check in the Locale bundle first, if the local has the same currency
ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
if (((String) bundle.getObject("IntCurrencySymbol")) //$NON-NLS-1$
.equals(currencyCode)) {
return (String) bundle.getObject("CurrencySymbol"); //$NON-NLS-1$
}
// search for a Currency bundle
bundle = null;
try {
bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
} catch (MissingResourceException e) {
return currencyCode;
}
// is the bundle found for a different country? (for instance the
// default locale's currency bundle)
if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
return currencyCode;
}
// check if the currency bundle for this locale
// has an entry for this currency
String result = (String) bundle.handleGetObject(currencyCode);
if (result != null) {
return result;
}
return currencyCode;