Here you can find the source of toShort(Object ob, Short defaultShort)
public static Short toShort(Object ob, Short defaultShort)
//package com.java2s; public class Main { public static Short toShort(Object ob, Short defaultShort) { if (ob == null) { return defaultShort; }// w ww .j av a2 s . c o m if (ob instanceof Integer) { return ((Integer) ob).shortValue(); } else if (ob instanceof Float) { return ((Float) ob).shortValue(); } else if (ob instanceof Double) { return ((Double) ob).shortValue(); } else if (ob instanceof Byte) { return ((Byte) ob).shortValue(); } else { try { return new Short(ob.toString()); } catch (Exception e) { return defaultShort; } } } public static Short toShort(Object ob) { return toShort(ob, Short.valueOf("0")); } }