public class LocaleUtils extends Object
Constructor and Description |
---|
LocaleUtils() |
Modifier and Type | Method and Description |
---|---|
static Locale |
toLocale(String input)
Converts a String to a Locale.
|
public LocaleUtils()
public static Locale toLocale(String input)
LocaleUtils.toLocale("en") = new Locale("en", "") LocaleUtils.toLocale("en_GB") = new Locale("en", "GB") LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#)(#) The behaviour of the JDK variant constructor changed between JDK1.3 and JDK1.4. In JDK1.3, the constructor upper cases the variant, in JDK1.4, it doesn't. Thus, the result from getVariant() may vary depending on your JDK. This method validates the input strictly. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore. The length must be correct.
input
- the locale String to convert, null returns nullIllegalArgumentException
- if the string is an invalid format5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.