code: public static int toIntWithDefault(String value, int defaultValue) {
  
          int result = defaultValue;
          try {
              result = Integer.parseInt(value);
          } catch (@SuppressWarnings("unused") Exception e) {
              // Do nothing, return default.
          }
          return result;
      }
docs: Parses int value and returns the provided default if the value can't be parsed.
  @param value the int to parse.
  @param defaultValue the default value.
  @return the parsed int, or the default value if parsing fails.