src/main/java/org/jboss/util/Strings.java
/**
    * Parse the given localeString into a {@link java.util.Locale}.
    *
    * This is the inverse operation of {@link java.util.Locale#toString Locale's toString}.
    *
    * @param localeString the locale string
    * @return a corresponding Locale instance
    */
Parse the given localeString into a  java.util.Locale.
This is the inverse operation of  java.util.Locale#toString Locale's toString.

@param localeString the locale string
@return a corresponding Locale instance
Parse the given localeString into a java . util . Locale . This is the inverse operation of java . util . Locale#toString Locale ' s toString . @param localeString the locale string @return a corresponding Locale instance
public static Locale parseLocaleString(String localeString)
   {
      String[] parts = tokenizeToStringArray(localeString, "_ ", false, false);
      String language = (parts.length > 0 ? parts[0] : "");
      String country = (parts.length > 1 ? parts[1] : "");
      String variant = "";
      if (parts.length >= 2)
      {
         int endIndexOfCountryCode = localeString.indexOf(country) + country.length();
         variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));
         if (variant.startsWith("_"))
         {
            variant = trimLeadingCharacter(variant, '_');
         }
      }
      return (language.length() > 0 ? new Locale(language, country, variant) : null);
   }
public static Locale parseLocaleString ( String localeString ) { String [ ] parts = tokenizeToStringArray ( localeString , "_ " , false , false ) ; String language = ( parts . length > 0 ? parts [ 0 ] : "" ) ; String country = ( parts . length > 1 ? parts [ 1 ] : "" ) ; String variant = "" ; if ( parts . length >= 2 ) { int endIndexOfCountryCode = localeString . indexOf ( country ) + country . length ( ) ; variant = trimLeadingWhitespace ( localeString . substring ( endIndexOfCountryCode ) ) ; if ( variant . startsWith ( "_" ) ) { variant = trimLeadingCharacter ( variant , '_' ) ; } } return ( language . length ( ) > 0 ? new Locale ( language , country , variant ) : null ) ; }
Parse the given localeString into a {@link java.util.Locale}.
Parse the given localeString into a { @link java . util . Locale } .
// There is definitely a variant, and it is everything after the country // code sans the separator between the country code and the variant. // Strip off any leading '_' and whitespace, what's left is the variant.