code: private Locale searchLocale(String language, String country,
                                  String variant) {
          Locale[] locales = Locale.getAvailableLocales();
          for (int i = 0; i < locales.length; i++) {
              if (locales[i].getLanguage().equals(language) &&
                 (country == null || locales[i].getCountry().equals(country)) &&
                 (variant == null || locales[i].getVariant().equals(variant))) {
                  return locales[i];
              }
          }
          return null;
      }
docs: Search the locale for specified language, specified country and
  specified variant.