code: public void writeBinary(final PacketOutputStream pos) throws IOException {
      Calendar calendar = Calendar.getInstance(timeZone);
      calendar.setTimeInMillis(ts.getTime());
  
      pos.write((byte) (fractionalSeconds ? 11 : 7));//length
  
      pos.writeShort((short) calendar.get(Calendar.YEAR));
      pos.write((byte) ((calendar.get(Calendar.MONTH) + 1) & 0xff));
      pos.write((byte) (calendar.get(Calendar.DAY_OF_MONTH) & 0xff));
      pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
      pos.write((byte) calendar.get(Calendar.MINUTE));
      pos.write((byte) calendar.get(Calendar.SECOND));
      if (fractionalSeconds) {
        pos.writeInt(ts.getNanos() / 1000);
      }
  
    }
docs: Write data to socket in binary format.
  
  @param pos socket output stream
  @throws IOException if socket error occur