code: private Locale getLocale() {
          Locale userlocale = null;
          if (localeName.length() > 0) {
              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) {
                          docenv.error(null, "main.malformed_locale_name", localeName);
                          return null;
                      }
                      country = localeName.substring(firstuscore + 1,
                                                     seconduscore);
                      variant = localeName.substring(seconduscore + 1);
                  } else if (localeName.length() == firstuscore + 3) {
                      country = localeName.substring(firstuscore + 1);
                  } else {
                      docenv.error(null, "main.malformed_locale_name", localeName);
                      return null;
                  }
              } else if (firstuscore == -1 && localeName.length() == 2) {
                  language = localeName;
              } else {
                  docenv.error(null, "main.malformed_locale_name", localeName);
                  return null;
              }
              userlocale = searchLocale(language, country, variant);
              if (userlocale == null) {
                  docenv.error(null, "main.illegal_locale_name", localeName);
                  return null;
              } else {
                  return userlocale;
              }
          } else {
              return Locale.getDefault();
          }
      }
docs: Get the locale if specified on the command line
  else return null and if locale option is not used
  then return default locale.