Here you can find the source of toShort(Object obj)
public static short toShort(Object obj)
//package com.java2s; //License from project: Open Source License public class Main { public static short toShort(Object obj) { return toShort(obj, (byte) 0); }//from w w w . java 2 s . c om public static short toShort(Object obj, short defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Number) { Number number = (Number) obj; return number.shortValue(); } String value = toString(obj); try { return Short.parseShort(value); } catch (Exception e) { return defaultValue; } } public static String toString(Object value) { if (value == null) { return ""; } return value.toString().trim(); } }