code: public static Integer toInteger(Object value) throws ConversionException {
          if (value == null) {
              return null;
          } else if (value instanceof Number) {
              return  ((Number)value).intValue();
          } else {
              NumberFormat nf = new DecimalFormat();
              try {
                  return nf.parse(value.toString()).intValue();
              } catch (ParseException e) {
                  throw new ConversionException("failed to convert: '" + value + "' to Integer", e);
              }
          }
      }
docs: Converts value to Integer if it can. If value is an Integer, it is returned, if it is a Number, it is
  promoted to Integer and then returned, in all other cases, it converts the value to String,
  then tries to parse Integer from it.
  
  @param value value to be converted to Integer.
  @return value converted to Integer.
  @throws ConversionException if failing to do the conversion