public static String getCountryISO2FromISO3 ( String iso3Code ) { iso3Code = StringUtils . trimToNull ( iso3Code ) ; if ( iso3Code == null ) return null ; if ( iso3Code . length ( ) == 3 ) { for ( String iso2Code : Locale . getISOCountries ( ) ) { Locale countryLocale = new Locale ( iso2Code , iso2Code ) ; String countryISO3 = StringUtils . trimToNull ( countryLocale . getISO3Country ( ) ) ; if ( countryISO3 != null && countryISO3 . equalsIgnoreCase ( iso3Code ) ) { return iso2Code ; } } } return null ; }
Create an ISO - 2 country code from an ISO - 3 country code .