code: private Locale getLocale(String localeName) throws ToolException {
          Locale userlocale = null;
          if (localeName == null || localeName.isEmpty()) {
              return Locale.getDefault();
          }
          int firstuscore = localeName.indexOf('_');
          int seconduscore = -1;
          String language = null;
          String country = null;
          String variant = null;
          if (firstuscore == 2) {
              language = localeName.substring(0, firstuscore);
              seconduscore = localeName.indexOf('_', firstuscore + 1);
              if (seconduscore > 0) {
                  if (seconduscore != firstuscore + 3
                          || localeName.length() <= seconduscore + 1) {
                      String text = messager.getText("main.malformed_locale_name", localeName);
                      throw new ToolException(CMDERR, text);
                  }
                  country = localeName.substring(firstuscore + 1,
                          seconduscore);
                  variant = localeName.substring(seconduscore + 1);
              } else if (localeName.length() == firstuscore + 3) {
                  country = localeName.substring(firstuscore + 1);
              } else {
                  String text = messager.getText("main.malformed_locale_name", localeName);
                  throw new ToolException(CMDERR, text);
              }
          } else if (firstuscore == -1 && localeName.length() == 2) {
              language = localeName;
          } else {
              String text = messager.getText("main.malformed_locale_name", localeName);
              throw new ToolException(CMDERR, text);
          }
          userlocale = searchLocale(language, country, variant);
          if (userlocale == null) {
              String text = messager.getText("main.illegal_locale_name", localeName);
              throw new ToolException(CMDERR, text);
          } else {
              return userlocale;
          }
      }
docs: Get the locale if specified on the command line
  else return null and if locale option is not used
  then return default locale.