From debfac58b0bf5fc34230bc359080d07cd087e745 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 14 Mar 2024 16:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=A7=A3=E6=9E=90=E5=85=BC?= =?UTF-8?q?=E5=AE=B9iso861=E5=B8=A6=E6=AF=AB=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java index f8ba4f2b..2bb9bfb1 100755 --- a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java @@ -35,6 +35,11 @@ public class DateUtil { */ private static final String ISO8601_ZONE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssXXX"; + /** + * 兼容的时间格式 iso8601时间格式带毫秒 + */ + private static final String ISO8601_MILLISECOND_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS"; + /** * wvp内部统一时间格式 */ @@ -55,6 +60,8 @@ public class DateUtil { public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); public static final DateTimeFormatter formatterZoneISO8601 = DateTimeFormatter.ofPattern(ISO8601_ZONE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); + public static final DateTimeFormatter formatterMillisecondISO8601 = DateTimeFormatter.ofPattern(ISO8601_MILLISECOND_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); + public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); @@ -70,6 +77,8 @@ public class DateUtil { return formatter.format(formatterCompatibleISO8601.parse(formatTime)); } else if (verification(formatTime, formatterZoneISO8601)) { return formatter.format(formatterZoneISO8601.parse(formatTime)); + } else if (verification(formatTime, formatterMillisecondISO8601)) { + return formatter.format(formatterMillisecondISO8601.parse(formatTime)); } return formatter.format(formatterISO8601.parse(formatTime)); }