美文网首页
Jackson之LocalDateTime转换

Jackson之LocalDateTime转换

作者: _3d7e | 来源:发表于2022-04-07 11:16 被阅读0次

    问题

    Jackson默认序列化会将LocalDateTime序列化成:

    {"dayOfMonth":15,"dayOfWeek":"SUNDAY","dayOfYear":258,"hour":14,"minute":6,"month":"SEPTEMBER","monthValue":9,"nano":359000000,"second":55,"year":2019,"chronology":{"id":"ISO","calendarType":"iso8601"}}
    

    特别是使用mybatis-plus入库时,看着这样一串东西,难受

    解决办法

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonDeserialize(using = LocalDateTimeDeserializer.class)
        @JsonSerialize(using = LocalDateTimeSerializer.class)
        private LocalDateTime passTime;
    

    相关文章

      网友评论

          本文标题:Jackson之LocalDateTime转换

          本文链接:https://www.haomeiwen.com/subject/kgbjsrtx.html