date格式序列化
//需要添加自定义序列化类
@Component
public class JsonDateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
String formattedDate = DateUtils.datetimeFormat.format(date);
jsonGenerator.writeString(formattedDate);
}
}
@Data
public static class ManageListResp {
private Integer id;
private String outOrderNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//指定自定义序列化
@JsonSerialize(using = JsonDateSerializer.class)
private Date gmtTrans;
private Integer depositChannel;
private String serial;
private String deviceCode;
private String trueName;
private String mobile;
}
作者:cchilei
-------------------------------------------
个性签名:竹杖芒鞋轻胜马 一蓑烟雨任平生
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!