public void writeTimestamp(TimestampWritableV2 timestamp, int byteNum) throws IOException {
    if (timestamp == null) {
      String pad = join("", Collections.nCopies(byteNum, " "));
      write(pad.getBytes("UTF8"));
      return;
    }
    String sTimeStamp = timestamp.getTimestamp().toString();
    if (sTimeStamp.length() >= byteNum) {
      write(sTimeStamp.substring(0, byteNum).getBytes("UTF8"));
      return;
    }
    write(sTimeStamp.getBytes("UTF8"));
    String pad;
    if (sTimeStamp.length() == TIMESTAMP_NO_NANOS_BYTE_NUM) {
      pad = "." + join("", Collections.nCopies(byteNum - sTimeStamp.length() - 1, "0"));
    } else {
      pad = join("", Collections.nCopies(byteNum - sTimeStamp.length(), "0"));
    }
    write(pad.getBytes("UTF8"));
  }
Write TIMESTAMP(N).
The representation of timestamp in Teradata binary format is:
the byte number to read is based on the precision of timestamp,
each byte represents one char and the timestamp is using string representation,
eg: for 1911-11-11 19:20:21.433200 in TIMESTAMP(3), we will cut it to be 1911-11-11 19:20:21.433 and write
31 39  31 31 2d 31 31 2d 31 31 20 31 39 3a 32 30 3a 32 31 2e 34 33 33.
the null timestamp will use space to pad.

@param timestamp the timestamp
@param byteNum the byte number the timestamp will write
@throws IOException the io exception
serde/src/java/org/apache/hadoop/hive/serde2/teradata/TeradataBinaryDataOutputStream.java