Serializing java.util.Date

前端 未结 2 1069
春和景丽
春和景丽 2020-12-19 03:07

Does anyone know how a java.util.Date gets serialized? I mean explain to me exactly what each byte is? I tried writing out a long then a date and I can see matches but the

2条回答
  •  执笔经年
    2020-12-19 03:22

    The details of the format of Java object serialisation are specified in Java Object Serialization Specification. Other than magic and version numbers , details of the Date class and the fact the object is a Date is written to the stream.

    The API doc for Date serialised form is:

    The value returned by getTime() is emitted (long). This represents the offset from January 1, 1970, 00:00:00 GMT in milliseconds.

    Note that it actually breaks the spec by not calling defaultWriteObject or putFields.

提交回复
热议问题