public static void writeDate(Date date, DataOutput out) throws IOException {

    InternalDataSerializer.checkOut(out);

    if (logger.isTraceEnabled(LogMarker.SERIALIZER_VERBOSE)) {
      logger.trace(LogMarker.SERIALIZER_VERBOSE, "Writing Date {}", date);
    }

    long v;
    if (date == null) {
      v = -1L;
    } else {
      v = date.getTime();
      if (v == -1L) {
        throw new IllegalArgumentException(
            "Dates whose getTime returns -1 can not be DataSerialized.");
      }
    }
    out.writeLong(v);
  }
Writes an instance of <code>Date</code> to a <code>DataOutput</code>. Note that even though
<code>date</code> may be an instance of a subclass of <code>Date</code>, <code>readDate</code>
will always return an instance of <code>Date</code>, <B>not</B> an instance of the subclass. To
preserve the class type of <code>date</code>,\ {@link #writeObject(Object, DataOutput)} should
be used for data serialization. This method will handle a <code>null</code> value and not throw
a <code>NullPointerException</code>.

@param date the <code>Date</code> to write
@param out the {@link DataInput} to write to

@throws IOException A problem occurs while writing to <code>out</code>

@see #readDate
geode-core/src/main/java/org/apache/geode/DataSerializer.java