From ec90b4070062c2831dcd0f1b6d8293ea611b0fb4 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 17 二月 2025 17:39:11 +0800
Subject: [PATCH] jtt808初始化

---
 server/services/src/main/java/com/doumee/core/utils/DateUtil.java |   76 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/core/utils/DateUtil.java b/server/services/src/main/java/com/doumee/core/utils/DateUtil.java
index f96e181..689c112 100644
--- a/server/services/src/main/java/com/doumee/core/utils/DateUtil.java
+++ b/server/services/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -10,6 +10,9 @@
 import java.text.DateFormatSymbols;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.Date;
 import java.util.*;
 
@@ -39,7 +42,18 @@
 
     public DateUtil() {
     }
+    public static Date getDateFromLocalDateTime(  LocalDateTime localDateTime) {
+        try {
+            ZoneId zoneId = ZoneId.systemDefault(); // 鑾峰彇绯荤粺榛樿鏃跺尯
+            ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId); // 杞崲涓哄甫鏃跺尯鐨勬棩鏈熸椂闂�
+            Date date = Date.from(zonedDateTime.toInstant()); // 杞崲涓篋ate
+            return  date;
+        }catch (Exception e){
 
+        }
+        return null;
+
+    }
     public static Date StringToDate2(String DATE) {
         if(StringUtils.isBlank(DATE)){
             return null;
@@ -291,6 +305,15 @@
             return nowDate;
         } catch (Exception e) {
             throw e;
+        }
+    }
+    public static String getShortDateStr(Date date)   {
+        String nowDate = "";
+        try {
+            nowDate = sdfShort.format(date);
+            return nowDate;
+        } catch (Exception e) {
+           return  null;
         }
     }
 
@@ -2298,6 +2321,16 @@
             return new Timestamp(System.currentTimeMillis());
         }
     }
+    public static Date getDateFromString2(String strDate) {
+        if (StringUtils.isEmpty(strDate)) {
+            return null;
+        }
+        try {
+            return sdfLongTimePlus.parse(strDate);
+        } catch (Exception ex) {
+           return  null;
+        }
+    }
 
     // -----------------------------------------------------------------------
     public static Date parseFromFormats(String aValue) {
@@ -2729,7 +2762,8 @@
 
     public static void main(String[] args) {
         try {
-            System.out.println(RandomStringUtils.randomNumeric(3));
+            System.out.println((int)(3.222));
+
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -2984,6 +3018,44 @@
         return cal.getTime();
     }
 
+
+    /**
+     * 2涓棩鏈熶箣闂寸浉宸垎閽熸暟
+     * @param begin
+     * @param end
+     * @return
+     */
+    public static Integer betweenMin(Date begin, Date end) {
+        if(begin ==null ){
+            return  0;
+        }
+        long createTime =begin.getTime();//鑾峰彇鍒涘缓鏃堕棿鐨勬椂闂存埑
+        long currentTime =Objects.isNull(end)?System.currentTimeMillis():end.getTime();//鑾峰彇褰撳墠鏃堕棿鐨勬椂闂存埑
+        long diff=(currentTime-createTime)/1000/60;//鑾峰彇涓や釜鏃堕棿鐩稿樊鐨勫垎閽�
+        return (int)diff + 1 ;
+    }
+
+    public static Integer between(Date begin, Date end) {
+        if(begin ==null ){
+            return  0;
+        }
+        long createTime =begin.getTime();//鑾峰彇鍒涘缓鏃堕棿鐨勬椂闂存埑
+        long currentTime =Objects.isNull(end)?System.currentTimeMillis():end.getTime();//鑾峰彇褰撳墠鏃堕棿鐨勬椂闂存埑
+        long diff=(currentTime-createTime)/1000/60;//鑾峰彇涓や釜鏃堕棿鐩稿樊鐨勫垎閽�
+        return (int)diff;
+    }
+
+    public static Integer betweenSeconds(Date begin, Date end) {
+        if(begin ==null ){
+            return  0;
+        }
+        long createTime =begin.getTime();//鑾峰彇鍒涘缓鏃堕棿鐨勬椂闂存埑
+        long currentTime =Objects.isNull(end)?System.currentTimeMillis():end.getTime();//鑾峰彇褰撳墠鏃堕棿鐨勬椂闂存埑
+        long diff=(currentTime-createTime)/1000;//鑾峰彇涓や釜鏃堕棿鐩稿樊鐨勫垎閽�
+        return (int)diff;
+    }
+
+
     /**
      * 璁$畻鑰楁椂
      * @param start
@@ -3003,4 +3075,4 @@
         return consuming.toString();
     }
 
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3