Java Integer Create toInteger(Object val)

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

Description

to Integer

License

Open Source License

Declaration

public static Integer toInteger(Object val) 

Method Source Code

//package com.java2s;

public class Main {
    public static Integer toInteger(Object val) {
        if (val == null)
            return null;
        if (val instanceof Number)
            return Integer.valueOf(((Number) val).intValue());

        return Integer.valueOf(val.toString().trim());
    }//from   ww  w .  j a va2 s.  co m

    public static String toString(int... results) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(' ');
        for (int i : results)
            sb.append(i).append(',');
        sb.setCharAt(sb.length() - 1, ' ');
        sb.append(']');
        return sb.toString();
    }
}

Related

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