Is there an open source java enum of ISO 3166-1 country codes

前端 未结 11 2634
南笙
南笙 2020-12-04 10:57

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

11条回答
  •  情话喂你
    2020-12-04 11:17

    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.

    Example:

    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
    

    Last Edit 2016-Jun-09

    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"
    

提交回复
热议问题