//需要添加自定义序列化类
@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;
}