Java Integer Create toInteger(Object object)

Here you can find the source of toInteger(Object object)

Description

to Integer

License

Open Source License

Declaration

public static Integer toInteger(Object object) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static Integer toInteger(Object object) {
        Integer integerValue;//from  ww w.ja  v a2 s  .c  o m
        if (object instanceof String) {
            integerValue = Integer.valueOf((String) object);
        } else if (object instanceof Number) {
            integerValue = ((Number) object).intValue();
        } else if (object == null) {
            integerValue = null;
        } else {
            throw new IllegalArgumentException("Failed to convert "
                    + object.getClass().getName() + " [" + object
                    + "] to an Integer.");
        }
        return integerValue;
    }
}

Related

  1. toInteger(Object ob, Integer defaultInteger)
  2. toInteger(Object obj)
  3. toInteger(Object obj)
  4. toInteger(Object obj)
  5. toInteger(Object object)
  6. toInteger(Object object, int defaultValue)
  7. toInteger(Object object, Integer defaultValue)
  8. toInteger(Object str)
  9. toInteger(Object val)