From 198a5dab9021d446154230a4c9d882d914770752 Mon Sep 17 00:00:00 2001 From: sjh Date: Mon, 6 Jan 2025 16:33:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=91=8A=E8=AD=A6=E5=88=86?= =?UTF-8?q?=E5=8F=91=E6=8E=A5=E5=8F=A3=E6=97=B6=E9=97=B4=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supervision/pojo/dto/jwdc/AlarmYjzjDto.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) 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); } } }