@JsonFormat的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39766167/article/details/85003046

@JsonFormat

我们可以有两种用法(我知道的),在对象属性上,或者在属性的 getter 方法上,

上面直接这么使用,在我们中国来讲和我们的北京时间,会相差8个小时,因为我们是东八区(北京时间)。

所以我们在格式化的时候要指定时区(timezone )

public class GlobalBO implements Serializable {
    private static final long serialVersionUID = -2938957948580534826L;

    private Long createUser;

    private String createCityCode;
    
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createDate;

猜你喜欢

转载自blog.csdn.net/qq_39766167/article/details/85003046