Java Object to Float objectToInt(Object o)

Here you can find the source of objectToInt(Object o)

Description

object To Int

License

Apache License

Declaration

public static final int objectToInt(Object o) 

Method Source Code

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

public class Main {
    public static final int objectToInt(Object o) {
        if (o instanceof Number)
            return ((Number) o).intValue();
        try {//  w w  w.  ja  va  2s .  com
            if (o == null)
                return -1;
            else
                return Integer.parseInt(o.toString());
        } catch (NumberFormatException e) {
            return -1;
        }
    }
}

Related

  1. castToFloat(final double v)
  2. castToFloat(final String uid)
  3. objectToFloat(Object o)
  4. objectToFloat(Object obj)
  5. objectToInt(Object o)
  6. objectToInt(Object Obj)
  7. objectToInt(Object obj)
  8. objectToInt(Object obj)
  9. objectToInt(Object p1)