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
I have created an enum, which you address by the english country name. See country-util.
On each enum you can call getLocale()
to get the Java Locale.
From the Locale you can get all the information you are used to, fx the ISO-3166-1 two letter country code.
public enum Country{
ANDORRA(new Locale("AD")),
AFGHANISTAN(new Locale("AF")),
ANTIGUA_AND_BARBUDA(new Locale("AG")),
ANGUILLA(new Locale("AI")),
//etc
ZAMBIA(new Locale("ZM")),
ZIMBABWE(new Locale("ZW"));
private Locale locale;
private Country(Locale locale){
this.locale = locale;
}
public Locale getLocale(){
return locale;
}
Pro:
Con: