PortableObjectSerializer 在序列化和反序列化 java.util.Date 时不准确 1 秒
对于像下面这样的代码,我注意到〜1秒的差异(序列化前很长时间= 1298298092890;反序列化后很长时间= 1298298093432)
public void readExternal(PofReader pReader) throws IOException {
//...0 to 8 omitted for brevity
tradeTimestamp =pReader.readDate(9);
entryTimestamp = pReader.readDate(10);
}
public void writeExternal(PofWriter pWriter) throws IOException {
//...0 to 8 omitted for brevity
pWriter.writeDate(9,tradeTimestamp);
pWriter.writeDate(10,entryTimestamp);
}
For the code like below, I notice a difference of ~ 1sec (long time before serialization=1298298092890; long time after deserialization=1298298093432)
public void readExternal(PofReader pReader) throws IOException {
//...0 to 8 omitted for brevity
tradeTimestamp =pReader.readDate(9);
entryTimestamp = pReader.readDate(10);
}
public void writeExternal(PofWriter pWriter) throws IOException {
//...0 to 8 omitted for brevity
pWriter.writeDate(9,tradeTimestamp);
pWriter.writeDate(10,entryTimestamp);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 API,writeDate 的精度有限。使用 writeDateTime 代替
According to the API, writeDate has a limited precision. use writeDateTime instead