Core/src/main/java/org/openestate/io/core/LocaleUtils.java
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;
    }
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;
    }
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.

@param iso3Code ISO-3 country code
@return ISO-2 country code or null, if no code was found
Create an ISO - 2 country code from an ISO - 3 country code .