public ByteWritable evaluate(TimestampWritableV2 i) {
    if (i == null) {
      return null;
    } else {
      final long longValue = UDFUtils.getTimestampTZFromTimestamp(i.getTimestamp()).getEpochSecond();
      final byte byteValue = (byte) longValue;
      if (byteValue != longValue) {
        return null;
      }
      byteWritable.set(byteValue);
      return byteWritable;
    }
  }
Convert from string to a byte. This is called for CAST(... AS TINYINT)

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