code: private static Integer toInt(String str) {
  
          Integer num = null;
          try {
              num = Integer.parseInt(str);
          } catch (NumberFormatException ex) {
              log.severe(String.format("failed to convert str: %s to integer", str));
          }
  
          return num;
      }
docs: Converts string to a number.
  
  @param str The string
  @return number or null if conversion failed