Here you can find the source of longToShort(long l)
public static Short longToShort(long l)
//package com.java2s; //License from project: LGPL public class Main { public static Short longToShort(long l) { if (l >= Short.MIN_VALUE && l <= Short.MAX_VALUE) { return (short) l; }//from ww w. j a v a2s . co m return null; } public static short longToShort(long l, short defaultValue) { if (l >= Short.MIN_VALUE && l <= Short.MAX_VALUE) { return (short) l; } return defaultValue; } }