public ShortWritable evaluate(TimestampWritableV2 i) {
    if (i == null) {
      return null;
    } else {
      final long longValue = UDFUtils.getTimestampTZFromTimestamp(i.getTimestamp()).getEpochSecond();
      final short shortValue = (short) longValue;
      if (shortValue != longValue) {
        return null;
      }
      shortWritable.set(shortValue);
      return shortWritable;
    }
  }
Convert from string to a short. This is called for CAST(... AS SMALLINT)

@param i
         The string value to convert
@return ShortWritable
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToShort.java