是否有ISO 3166-1国家/地区代码的开源java枚举 [英] Is there an open source java enum of ISO 3166-1 country codes

查看:1641
本文介绍了是否有ISO 3166-1国家/地区代码的开源java枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道免费提供的java 1.5软件包,它提供了一个ISO 3166-1国家/地区代码列表作为枚举或EnumMap?具体来说,我需要ISO 3166-1-alpha-2代码元素,即2个字符的国家代码,如us,uk,de等。创建一个很简单(虽然单调乏味),但如果在apache land或者类似的地方已经存在一个标准的,它会节省一点时间。

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 / 数字)列表,因为Java枚举可用在Apache许可证版本2.0下的GitHub。

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月 - 09月


Last Edit 2016-Jun-09

CountryCode枚举与其他Java枚举,LanguageCode( ISO 639-1 ),LanguageAlpha3Code( ISO 639-2 ),LocaleCode,ScriptCode( ISO 15924 )和CurrencyCode( ISO 4217 )并注册到Maven Central Repository。

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

<dependency>
  <groupId>com.neovisionaries</groupId>
  <artifactId>nv-i18n</artifactId>
  <version>1.22</version>
</dependency>

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"

这篇关于是否有ISO 3166-1国家/地区代码的开源java枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆