Java Integer Create toInteger(Object val)

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

Description

to Integer

License

Apache License

Declaration

public static Integer toInteger(Object val) 

Method Source Code

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

public class Main {

    public static Integer toInteger(Object val) {
        return toLong(val).intValue();
    }// w w  w . j a  v a  2  s . co m

    public static Long toLong(Object val) {
        return toDouble(val).longValue();
    }

    public static Double toDouble(Object val) {
        if (val == null) {
            return 0D;
        }
        try {
            return Double.valueOf(trim(val.toString()));
        } catch (Exception e) {
            return 0D;
        }
    }

    public static String trim(String str) {
        return (null == str) ? null : str.trim();
    }
}

Related

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