public IntWritable evaluate(TimestampWritableV2 i) {
    if (i == null) {
      return null;
    } else {
      final long longValue = UDFUtils.getTimestampTZFromTimestamp(i.getTimestamp()).getEpochSecond();
      final int intValue = (int) longValue;
      if (intValue != longValue) {
        return null;
      }
      intWritable.set(intValue);
      return intWritable;
    }
  }
Convert from Timestamp to an integer. This is called for CAST(... AS INT)

@param i
         The Timestamp value to convert
@return IntWritable
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToInteger.java