Java Integer Create toIntegerByObject(Object obj)

Here you can find the source of toIntegerByObject(Object obj)

Description

to Integer By Object

License

Apache License

Declaration

public static Integer toIntegerByObject(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static Integer toIntegerByObject(Object obj) {
        try {//from  w  ww.j  av  a2 s. c o  m
            return Integer.valueOf(toStringByObject(obj, true));
        } catch (Exception e) {
            return 0;
        }
    }

    public static String toStringByObject(Object obj) {
        return toStringByObject(obj, false);
    }

    public static String toStringByObject(Object obj, boolean isqdkg) {
        if (obj == null) {
            return "";
        } else {
            if (isqdkg) {
                return obj.toString().trim();
            } else {
                return obj.toString();
            }

        }
    }
}

Related

  1. toIntegerArray(double[] doubles)
  2. toIntegerArray(final int[] array)
  3. toIntegerArray(final int[] ints)
  4. toIntegerArray(String text, String delimiter)
  5. toIntegerArray(String... values)
  6. toIntegerFromObj(Object obj)
  7. toIntegerObject(boolean bool)
  8. toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue)
  9. toIntegerOrNull(String s)