Java Object to Long objectToShort(Object o)

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

Description

object To Short

License

Apache License

Declaration

public static final short objectToShort(Object o) 

Method Source Code

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

public class Main {
    public static final short objectToShort(Object o) {
        if (o instanceof Number)
            return ((Number) o).shortValue();
        try {//  w  w  w .j ava  2 s.  com
            if (o == null)
                return -1;
            else
                return Short.parseShort(o.toString());
        } catch (NumberFormatException e) {
            return -1;
        }
    }
}

Related

  1. castToLong(Object value)
  2. castToLong(Object value)
  3. castToLongArray(Object[] array)
  4. objectToLong(Object obj)
  5. objectToPostiveLong(Object object)
  6. objectToShort(Object p1)