title: web前端el-date-picker 组件前端时间入库会少一天的问题(结合SpringBoot)
date: 2020-10-12
tags: markdown
categories: 编程
问题原因:前后端发送接收的 “时间格式不一致”
问题解决
前端格式:
在 el-date-picker组件上设置时间格式 value-format="yyyy-MM-dd"
Spring后端时间格式,传参通过 @JsonFormat 注解设置格式和时区
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birth;
当前后端日期显示有误时,应该考虑到时间格式不一致或者时区不一致的问题。