获取国家代码/名称鉴于我有货币代码,我如何获取货币适用的国家代码/名称?我知道货币和国家之间可能会有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. 从Objective-C中获取货币代码的货币符号
- 3. 是否可以从货币代码中导出货币符号?
- 4. 如何找出货币的html代码?
- 5. C#格式货币给定货币代码(如USD/GBP/FRF)
- 6. 从货币代码中获取CultureInfo?
- 7. 货币代码返回无
- 8. 如何将货币符号转换为iOS中的货币代码?
- 9. 在magento显示货币代码和货币符号
- 10. 转换成ISO 4217的数字货币代码货币名称
- 11. 如何使用Apache POI从Excel中获取货币代码?
- 12. 如何从货币代码中获取NumberFormat实例?
- 13. 如何从priceLocale获取货币代码(样本120¥)?
- 14. 从货币
- 15. 货币掩码jqgrid
- 16. 获取国家的货币代码
- 17. 货币符号和代码动态
- 18. 经由代码在C#改变货币
- 19. NumberFormat不显示货币代码
- 20. 在线货币交易.. php代码
- 21. 货币格式代码Microsoft Chart SSRS
- 22. 如何通过货币代码设置iOS NSNumberFormatter区域设置?
- 23. 如何将国家名称转换为货币代码?
- 24. Magento:如何在所有总计后显示货币代码?
- 25. 如何通过IP地址获取国家代码和货币代码?
- 26. jQuery的货币掩码
- 27. WPF从后面的代码格式化货币列
- 28. 从国家代码获取货币信息在PHP
- 29. 在Grails中代表货币(价值+货币)的最佳实践
- 30. 我如何检索只货币符号,而不从angularjs货币过滤
您可以在货币/国家组合存储在数据库中的表。当财务状况发生变化时,您需要更新表格。 – 2015-04-06 11:08:08
不想自己维护映射。这不是一些API吗? – akrohit 2015-04-06 11:09:19