使用ObjectMapper从带有JSON的ZoneDateTime反序列化错误 [英] Incorrect deserialisation of ZoneDateTime from JSON with ObjectMapper

查看:368
本文介绍了使用ObjectMapper从带有JSON的ZoneDateTime反序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到 long = 1417471200000 这应该是 2017 年,但是,当反序列化ZoneDateTime时,其值为 + 48908-06-13 16:00:00
我已经拥有maven依赖

i'm receiving long = 1417471200000 which should be 2017 year, but, when ZoneDateTime is deserialized its value is +48908-06-13 16:00:00 i'm already have maven dependency of

<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.6.5</version>

我犯了哪个错误?

另外,当我将这个错误的 ZoneDateTime 对象反序列化为 long 时,其值又回来了 1417471200000

also, when i deserialize this wrong ZoneDateTime object to long, its value is back again 1417471200000

推荐答案

您在这里的时间似乎是以毫秒为单位:

The time you have here appears to be in milliseconds:

1417471200      = Mon Dec  1 22:00:00 GMT 2014
1417471200000   = Sat Nov 15 16:00:00 GMT 46887

您将毫秒数传递给预期时间的秒数。

You're passing the milliseconds to something that expects time in seconds.

这篇关于使用ObjectMapper从带有JSON的ZoneDateTime反序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆