获取国家代码/名称鉴于我有货币代码,我如何获取货币适用的国家代码/名称?我知道货币和国家之间可能会有1:n的映射关系,那么该如何获得货币适用的所有国家?如何从货币代码
Q
如何从货币代码
1
A
回答
0
为了获得货币的所有国家,您可以运行一个简单的搜索到Java中的MultiMap对象。通过在地图上运行搜索(例如,第一个字符串是货币,第二个是国家)以及如果检查货币是否是您要查找的货币。如果是这样,您可以将所有找到的国家添加到数组中,然后进一步使用它们。
0
CurrencyCode
类nv-i18n库有getCountryList()
方法返回使用货币的国家列表。以下是一个示例命令行应用程序。
import java.util.List;
import com.neovisionaries.i18n.CountryCode;
import com.neovisionaries.i18n.CurrencyCode;
public class CurrencyToCountryList
{
public static void main(String[] args)
{
// For each currency code such as EUR and USD.
for (String code : args)
{
// Get a CurrencyCode instance.
CurrencyCode currency =
CurrencyCode.getByCode(code);
if (currency == null)
{
// The code is invalid.
System.out.format("'%s' is invalid.\n", code);
continue;
}
System.out.format("%s (%s) is used by:\n",
currency, currency.getName());
// Get the list of countries using the currency.
List<CountryCode> countryCodeList =
currency.getCountryList();
// For each country.
for (CountryCode country : countryCodeList)
{
// Print the country code and the country name.
System.out.format("\t%s: %s\n",
country, country.getName());
}
}
}
}
如果你运行这个应用程序是这样的:
$ java -cp nv-i18n-1.15.jar:. CurrencyToCountryList USD
您将得到如下结果:
USD (US Dollar) is used by:
AS: American Samoa
BQ: Bonaire, Sint Eustatius and Saba
EC: Ecuador
FM: Micronesia, Federated States of
GU: Guam
HT: Haiti
IO: British Indian Ocean Territory
MH: Marshall Islands
MP: Northern Mariana Islands
PA: Panama
PR: Puerto Rico
PW: Palau
SV: El Salvador
TC: Turks and Caicos Islands
TL: Timor-Leste
UM: United States Minor Outlying Islands
US: United States
VG: Virgin Islands, British
VI: Virgin Islands, U.S.
相关问题
- 1. 如何从iphone中的货币代码获取货币符号?
- 2. 根据货币代码将货币格式设置为货币
- 3. iOS如何通过货币代码获取货币符号?
- 4. 是否可以从货币代码中导出货币符号?
- 5. 从货币代码中提取货币符号Yii
- 6. 从Objective-C中获取货币代码的货币符号
- 7. 如何找出货币的html代码?
- 8. C#格式货币给定货币代码(如USD/GBP/FRF)
- 9. 从货币代码中获取CultureInfo?
- 10. 货币代码返回无
- 11. django国家货币代码
- 12. 如何在货币符号中更改货币代码缩写Magento
- 13. 如何将货币符号转换为iOS中的货币代码?
- 14. 转换成ISO 4217的数字货币代码货币名称
- 15. 3位货币代码到货币符号
- 16. 根据ISOCountryCode获取货币符号和货币代码
- 17. 在magento显示货币代码和货币符号
- 18. 如何从货币代码中获取NumberFormat实例?
- 19. 如何使用Apache POI从Excel中获取货币代码?
- 20. 如何从priceLocale获取货币代码(样本120¥)?
- 21. 如何从货币代码中获取NSLocale?
- 22. 如何代表货币或货币使用C
- 23. 如何从NumberFormat的货币especific改变为美元货币
- 24. 从货币
- 25. 货币掩码jqgrid
- 26. 在线货币交易.. php代码
- 27. 商店货币代码以及价格
- 28. 货币符号和代码动态
- 29. 货币代码是在Xcode ES-419
- 30. 经由代码在C#改变货币
您可以在货币/国家组合存储在数据库中的表。当财务状况发生变化时,您需要更新表格。 – 2015-04-06 11:08:08
不想自己维护映射。这不是一些API吗? – akrohit 2015-04-06 11:09:19