时间数据定义的格式
数据库时间字段定义的格式![在这里插入图片描述](https://img-blog.csdnimg.cn/20210525164622654.png)
实体类属性定义的格式
解决方法
1. 在springboot配置文件添加如下:
spring:
jackson:
# 格式化返回时间 yyyy-MM-dd HH:mm:ss
date-format: yyyy-MM-dd HH:mm:ss
# 设置时区
time-zone: GMT+8
在项目全局生效
2. 在实体类属性上添加注解如下:
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date gmtCreate;
仅对该字段生效