Jackson之LocalDateTime转换
2022-04-07 本文已影响0人
_3d7e
问题
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;