问题描述
有谁知道一个免费提供的 java 1.5 包,它以枚举或 enummap 的形式提供 iso 3166-1 国家代码列表?具体来说,我需要iso 3166-1-alpha-2 代码元素",即 2 个字符的国家/地区代码,例如us"、uk"、de"等.创建一个很简单(虽然很乏味),但是如果在 apache 领域或类似的地方已经有一个标准的,它会节省一点时间.
does anyone know of a freely available java 1.5 package that provides a list of iso 3166-1 country codes as a enum or enummap? specifically i need the "iso 3166-1-alpha-2 code elements", i.e. the 2 character country code like "us", "uk", "de", etc. creating one is simple enough (although tedious), but if there's a standard one already out there in apache land or the like it would save a little time.
推荐答案
现在实现了国家代码 (iso 3166-1 alpha-2/alpha-3/numeric) 列表作为 java 枚举在 github 上可用 apache 许可证版本 2.0.
now an implementation of country code (iso 3166-1 alpha-2/alpha-3/numeric) list as java enum is available at github under apache license version 2.0.
示例:
countrycode cc = countrycode.getbycode("jp"); system.out.println("country name = " cc.getname()); // "japan" system.out.println("iso 3166-1 alpha-2 code = " cc.getalpha2()); // "jp" system.out.println("iso 3166-1 alpha-3 code = " cc.getalpha3()); // "jpn" system.out.println("iso 3166-1 numeric code = " cc.getnumeric()); // 392
<小时>
上次编辑 2016 年 6 月 9 日
last edit 2016-jun-09
countrycode 枚举与其他 java 枚举、languagecode (iso 639- 一起打包到 com.neovisionaries.i18n1)、languagealpha3code (iso 639-2)、localecode、scriptcode (iso 15924) 和 currencycode (iso 4217) 并注册到 maven 中央存储库.
countrycode enum was packaged into com.neovisionaries.i18n with other java enums, languagecode (iso 639-1), languagealpha3code (iso 639-2), localecode, scriptcode (iso 15924) and currencycode (iso 4217) and registered into the maven central repository.
maven
com.neovisionaries nv-i18n 1.22
gradle
dependencies { compile 'com.neovisionaries:nv-i18n:1.22' }
github
https://github.com/takahikokawasaki/nv-i18n
javadoc
http://takahikokawasaki.github.com/nv-i18n/
osgi
bundle-symbolicname: com.neovisionaries.i18n export-package: com.neovisionaries.i18n;version="1.22.0"