code: private Locale searchLocale(String language, String country,
                                  String variant) {
          for (Locale loc : Locale.getAvailableLocales()) {
              if (loc.getLanguage().equals(language) &&
                  (country == null || loc.getCountry().equals(country)) &&
                  (variant == null || loc.getVariant().equals(variant))) {
                  return loc;
              }
          }
          return null;
      }
docs: Search the locale for specified language, specified country and
  specified variant.