@ -781,12 +781,15 @@ public abstract class StringUtils {
@@ -781,12 +781,15 @@ public abstract class StringUtils {
/ * *
* Parse the given { @code String } representation into a { @link Locale } .
* < p > This is the inverse operation of { @link Locale # toString Locale ' s toString } .
* < p > For many parsing scenarios , this is an inverse operation of
* { @link Locale # toString Locale ' s toString } , in a lenient sense .
* This method does not aim for strict { @code Locale } design compliance ;
* it is rather specifically tailored for typical Spring parsing needs .
* < p > < b > Note : This delegate does not accept the BCP 47 language tag format .
* Please use { @link # parseLocale } for lenient parsing of both formats . < / b >
* @param localeString the locale { @code String } : following { @code Locale ' s }
* { @code toString ( ) } format ( "en" , "en_UK" , etc ) , also accepting spaces as
* separators ( as an alternative to underscores )
* < p > Note : This variant does not accept the BCP 47 language tag format .
* Please use { @link # parseLocale } for lenient parsing of both formats .
* @return a corresponding { @code Locale } instance , or { @code null } if none
* @throws IllegalArgumentException in case of an invalid locale specification
* /
@ -817,6 +820,12 @@ public abstract class StringUtils {
@@ -817,6 +820,12 @@ public abstract class StringUtils {
variant = trimLeadingCharacter ( variant , '_' ) ;
}
}
if ( "" . equals ( variant ) & & country . startsWith ( "#" ) ) {
variant = country ;
country = "" ;
}
return ( language . length ( ) > 0 ? new Locale ( language , country , variant ) : null ) ;
}