Here you can find the source of toShort(Object value)
public static Short toShort(Object value)
//package com.java2s; //License from project: Apache License public class Main { /**// w w w . j av a 2 s . c om * Convert an Object to a Short. */ public static Short toShort(Object value) { if (value == null) return null; if (value instanceof Short) return (Short) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Short((String) value); } if (value instanceof Number) return new Short(((Number) value).shortValue()); return new Short(value.toString()); } /** * Convert an Object to a short, or 0 if it is null. */ public static short shortValue(Object value) { if (value == null) return 0; return toShort(value).shortValue(); } }