code: public static Locale asLocale(final String value) {
          final Locale locale;
          final int p = value.indexOf("__");
          if (p > -1) {
              locale = new Locale(value.substring(0, p), null, value.substring(p + 2));
          } else {
              final StringTokenizer tok = new StringTokenizer(value, "_");
              if (tok.countTokens() == 1) {
                  locale = new Locale(value);
              } else if (tok.countTokens() == 2) {
                  locale = new Locale(tok.nextToken(), tok.nextToken());
              } else if (tok.countTokens() == 3) {
                  locale = new Locale(tok.nextToken(), tok.nextToken(), tok.nextToken());
              } else {
                  throw new IllegalArgumentException("Cannot convert: '" + value + "'");
              }
          }
          return locale;
      }
docs: Returns the given string as locale. The locale is NOT checked against the Java list of avilable locales.
  
  @param value
  Value to convert into a locale.
  
  @return Locale.