返回日期字段一行代码进行格式化处理

  1. 方法1: 使用@JsonFormat注解(放在date属性或者其get方法上都可以)

    @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss") 
    private Date createTime; 
    
  2. 方法2: 在配置文件中配置spring.jackson.date-format

    spring:
      jackson:
        date-format: yyyy-MM-dd HH:mm:ss
    

猜你喜欢

转载自blog.csdn.net/qq_26496077/article/details/114638726