public static void convertTimestampToBytes(Timestamp t, byte[] b,
      int offset) {
    long seconds = t.toEpochSecond();
    int nanos = t.getNanos();

    boolean hasSecondVInt = seconds < 0 || seconds > Integer.MAX_VALUE;
    boolean hasDecimal = setNanosBytes(nanos, b, offset+4, hasSecondVInt);

    int firstInt = (int) seconds;
    if (hasDecimal || hasSecondVInt) {
      firstInt |= DECIMAL_OR_SECOND_VINT_FLAG;
    } else {
      firstInt &= LOWEST_31_BITS_OF_SEC_MASK;
    }
    intToBytes(firstInt, b, offset);

    if (hasSecondVInt) {
      LazyBinaryUtils.writeVLongToByteArray(b,
          offset + 4 + WritableUtils.decodeVIntSize(b[offset + 4]),
          seconds >> 31);
    }
  }
Writes a Timestamp's serialized value to byte array b at the given offset
@param t to convert to bytes
@param b destination byte array
@param offset destination offset in the byte array
serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampWritableV2.java