springboot项目中使用Timestamp类型变量对应mybatis的Timestamp格式的列前端
数据库中显示的时间正常,但Spring boot实际获取的时间格式相似于: "time": "2019-12-31T16:10:00.000+0000"
, 前端须要使用标准显示的格式,好比"2019-12-31 16:10:00"
. spring
后端改更容易一些, 只需在Timestamp变量上加一个@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
便可。 数据库
完整的Entity以下:后端
@AllArgsConstructor @Data public class PriceReturnEntity { private String price; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Timestamp time; }
实际JsonFormat还能够更改时区等等, 这个能够查看个人另外一篇blogspringboot