Springboot configuration file configures global date formatting method

1. You can add the following configuration to apllication.property

#Uniform timestamp conversion
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8

two,

@JsonFormat(timezone = "GMT+8", pattern = "yyyyMMddHHmmss")
private Date createTime; 

3. You can add the following configuration to apllication.yml (recommended)

spring:
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss

Guess you like

Origin blog.csdn.net/weixin_55127182/article/details/131731160