From fc74ce9de4c38d56ee429893758776eeb5432e9b Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 31 一月 2024 17:25:32 +0800
Subject: [PATCH] Merge branch '2.6.9' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

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 93d4086..e5f9fe4 100755
--- a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -89,7 +89,7 @@
      * 鏃堕棿鎴� 杞� yyyy_MM_dd
      */
     public static String timestampTo_yyyy_MM_dd(long timestamp) {
-        Instant instant = Instant.ofEpochSecond(timestamp);
+        Instant instant = Instant.ofEpochMilli(timestamp);
         return DateFormatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
     }
 
@@ -139,4 +139,13 @@
         Instant beforeInstant = Instant.from(formatter.parse(keepaliveTime));
         return ChronoUnit.MILLIS.between(beforeInstant, Instant.now());
     }
+
+    public static long getDifference(String startTime, String endTime) {
+        if (ObjectUtils.isEmpty(startTime) || ObjectUtils.isEmpty(endTime)) {
+            return 0;
+        }
+        Instant startInstant = Instant.from(formatter.parse(startTime));
+        Instant endInstant = Instant.from(formatter.parse(endTime));
+        return ChronoUnit.MILLIS.between(endInstant, startInstant);
+    }
 }

--
Gitblit v1.8.0