在研究了ISO表和Currency类文档之后,您似乎可以将货币作为代码或语言环境了。并且Locale类有一个getAvailableLocales()
方法。
因此,代码为:
public static Set<Currency> getAllCurrencies()
{
Set<Currency> toret = new HashSet<Currency>();
Locale[] locs = Locale.getAvailableLocales();
for(Locale loc : locs) {
try {
Currency currency = Currency.getInstance( loc );
if ( currency != null ) {
toret.add( currency );
}
} catch(Exception exc)
{
// Locale not found
}
}
return toret;
}
希望这可以帮助。