要解决这个问题其实很简单, 在接收的字段上面,添加下面的注解 就可以了
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") //返回时间类型
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") //接收时间类型
private Date startTime;
注解解释:
@DateTimeFormat
该注解自动会解析处理,会把字符串类型 按照格式yyyy-MM-dd HH:mm:ss 转换成时间类型
@JsonFormat
这个注解是spring里面controller返回到页面的的转换. 把时间类型 转换成JSON格式类型,
前提取出进行展示.