648540858
2024-01-08 b15e559eae82db811b31f1e3c47e3be027f20e27
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);
    }
}