Class LocaleCountryConverter
java.lang.Object
com.flowingcode.vaadin.addons.localecombobox.LocaleCountryConverter
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToISO3166Code(String countryCode) Converts a country code to its corresponding ISO 3166-1 alpha-2 code.
-
Constructor Details
-
LocaleCountryConverter
public LocaleCountryConverter()
-
-
Method Details
-
convertToISO3166Code
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
Optionalcontaining the ISO 3166-1 alpha-2 code if the conversion is successful.
-