@DateTimeFormat 和 @JsonFormat 注解

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_34845394/article/details/99899436

入参格式化

@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
public class DateVo {
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date date;
 
    public void setDate(Date date){
        this.date = date;
    }
    public Date getDate(){
        return date;
    }
}

出参格式化

// 时区
timezone = "GMT+8"
@JsonFormat(
    pattern = "yyyy-MM-dd HH:mm:ss",
    timezone = "GMT+8"
)
private Date date;

感谢

猜你喜欢

转载自blog.csdn.net/qq_34845394/article/details/99899436