code: public static Locale fallback(Locale loc) {
  
          // Split the locale into parts and remove the rightmost part
          String[] parts = new String[]
              { loc.getLanguage(), loc.getCountry(), loc.getVariant() };
          int i;
          for (i=2; i>=0; --i) {
              if (parts[i].length() != 0) {
                  parts[i] = "";
                  break;
              }
          }
          if (i<0) {
              return null; // All parts were empty
          }
          return new Locale(parts[0], parts[1], parts[2]);
      }
docs: Fallback from the given locale name by removing the rightmost _-delimited
  element. If there is none, return the root locale ("", "", ""). If this
  is the root locale, return null. NOTE: The string "root" is not
  recognized; do not use it.
  
  @return a new Locale that is a fallback from the given locale, or null.