我一直遇到问题,一直使用Spring Boot和Jackson-databind 2.5.2将Joda DateTime从java序列化和反序列化为json,然后再将其反序列化.我的pom.xml看起来像这样.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我序列化DateTime对象时,我得到一个表示DateTime的整数.不是我的预期,但很好.但是当我去保存我的对象时,我得到以下错误...
Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'endTime';
nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type org.joda.time.DateTime for value '1428600998511'
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它将序列化为一个整数,然后将其反序列化,就像它是一个字符串,它不是.我还尝试在调用其余服务之前设置endTime = new Date(intValue),并且尝试将字符串转换为类似'Tue Apr 28 2015 00:00:00 GMT-0700(PDT)'的字符串也失败了.
我究竟做错了什么?
更新:
下面是我得到的JSON 和我试图立即发布右后卫.
{
id: 4,
username: "",
name: "eau",
email: "aoue",
verbatimLocation: null,
latitude: null,
longitude: null, …Run Code Online (Sandbox Code Playgroud) 我已经下载了Tomcat 8并在我所需的路径中复制了解压缩的文件夹.我在运行我的网络应用程序时使用这个tomcat作为我的服务器.
当我使用java时间包访问系统默认时区时,实际上是我得到的时区.它是系统的时钟设置吗?或者是tomcat的设置.
我在哪里可以设置tomcat的时区.