code: public static Locale toLocale(String localeString)
      {
          if ((localeString == null) || (localeString.length() == 0))
          {
              Locale locale = Locale.getDefault();
              if(log.isLoggable(Level.WARNING))
              {
                  log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : "
                          + locale.toString());
              }
              return locale;
          }
  
          int separatorCountry = localeString.indexOf('_');
          char separator;
          if (separatorCountry >= 0)
          {
              separator = '_';
          }
          else
          {
              separatorCountry = localeString.indexOf('-');
              separator = '-';
          }
  
          String language;
          String country;
          String variant;
          if (separatorCountry < 0)
          {
              language = localeString;
              country = "";
              variant = "";
          }
          else
          {
              language = localeString.substring(0, separatorCountry);
  
              int separatorVariant = localeString.indexOf(separator, separatorCountry + 1);
              if (separatorVariant < 0)
              {
                  country = localeString.substring(separatorCountry + 1);
                  variant = "";
              }
              else
              {
                  country = localeString.substring(separatorCountry + 1, separatorVariant);
                  variant = localeString.substring(separatorVariant + 1);
              }
          }
  
          return new Locale(language, country, variant);
      }
docs: Converts a locale string to <code>Locale</code> class. Accepts both
  '_' and '-' as separators for locale components.
  
  @param localeString string representation of a locale
  @return Locale instance, compatible with the string representation