在数据库里的时间格式为: DATE 类型
2022-09-21 10:41:00
接口返回时,格式变成了
2022-09-21T10:41:00.000+0800
一般情况下在实体类字段上加@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 注解能解决90%的情况
- import java.util.Date;
- import com.fasterxml.jackson.annotation.JsonFormat;
- import org.springframework.format.annotation.DateTimeFormat;
-
- @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date gmtCreate;