diff --git a/src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java b/src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java index 807ab4c..fefb94d 100644 --- a/src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java +++ b/src/main/java/com/biutag/supervision/pojo/dto/jwdc/AlarmYjzjDto.java @@ -8,9 +8,8 @@ import lombok.Setter; import java.io.IOException; import java.math.BigDecimal; -import java.time.Instant; import java.time.LocalDateTime; -import java.time.ZoneId; +import java.time.format.DateTimeFormatter; @Setter @Getter @@ -77,17 +76,12 @@ public class AlarmYjzjDto { super(LocalDateTime.class); } + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + @Override public LocalDateTime deserialize(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.databind.DeserializationContext ctxt) throws IOException { - String dateStr = p.getText(); - if (dateStr.startsWith("/Date(") && dateStr.endsWith(")/")) { - String timestampStr = dateStr.substring(6, dateStr.length() - 2); - // 去掉时区部分 - String[] parts = timestampStr.split("-"); - long timestamp = Long.parseLong(parts[0]); - return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()); - } - throw new IllegalArgumentException("Invalid date format: " + dateStr); + String date = p.getText(); + return LocalDateTime.parse(date, FORMATTER); } } }