Class LocaleCountryConverter

java.lang.Object
com.flowingcode.vaadin.addons.localecombobox.LocaleCountryConverter

public class LocaleCountryConverter extends Object
Utility class for converting between different formats of country codes.

The LocaleCountryConverter class provides methods to convert country codes from ISO 3166-1 alpha-2, alpha-3, and numeric-3 formats to the 3166-1 alpha-2 format. The class uses static methods, so no instances are needed.

Example usage:

 String alpha2Code = LocaleCountryConverter.convertToISO3166Code("ARG").orElse("Unknown");
 
See Also:
  • Constructor Details

    • LocaleCountryConverter

      public LocaleCountryConverter()
  • Method Details

    • convertToISO3166Code

      public static Optional<String> convertToISO3166Code(String countryCode)
      Converts a country code to its corresponding ISO 3166-1 alpha-2 code.
      Parameters:
      countryCode - The country code to be converted. This can be in ISO 3166-1 alpha-2 format (e.g., "AR"), ISO 3166-1 alpha-3 format (e.g., "ARG"), or numeric-3 format (e.g., "032").
      Returns:
      An Optional containing the ISO 3166-1 alpha-2 code if the conversion is successful.