From 6765787baa5e0b771d71f865c4deb776367410c4 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 13 八月 2024 13:38:19 +0800
Subject: [PATCH] 修复bug

---
 server/dmvisit_service/src/main/java/com/doumee/core/utils/DateUtil.java |   73 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 5 deletions(-)

diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/utils/DateUtil.java b/server/dmvisit_service/src/main/java/com/doumee/core/utils/DateUtil.java
index c9be133..2ccb323 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/core/utils/DateUtil.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -50,7 +50,24 @@
         try {
             TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
             //TimeZone tz = TimeZone.getTimeZone("GMT-01");
-            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+'z");
+            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+'08:00");
+            df.setTimeZone(tz);
+            String nowAsISO = df.format(date);
+            return nowAsISO;
+        }catch (Exception e){
+        }
+        return  null;
+    }
+    /**
+     * 浼犲叆Data绫诲瀷鏃ユ湡锛岃繑鍥炲瓧绗︿覆绫诲瀷鏃堕棿锛圛SO8601鏍囧噯鏃堕棿锛�
+     * @param date
+     * @return
+     */
+    public static String getISO8601Timestamp2(Date date){
+        try {
+            TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
+            //TimeZone tz = TimeZone.getTimeZone("GMT-01");
+            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'+'08:00");
             df.setTimeZone(tz);
             String nowAsISO = df.format(date);
             return nowAsISO;
@@ -68,6 +85,25 @@
         }
         //TimeZone tz = TimeZone.getTimeZone("GMT-01");
         DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
+//        DateFormat df = new SimpleDateFormat("2023-12-08 T 09:25:54.698+08:00");
+        df.setTimeZone(tz);
+        Date nowAsISO = null;
+        try {
+            nowAsISO = df.parse(date);
+        } catch (ParseException e) {
+        }
+        return nowAsISO;
+    }
+    public static Date getISO8601DateByStr2(String date)  {
+        TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
+        if(date!=null ){
+            int i = date.indexOf("+");
+            if(i >0){
+                date = date.substring(0,i);
+            }
+        }
+        //TimeZone tz = TimeZone.getTimeZone("GMT-01");
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
 //        DateFormat df = new SimpleDateFormat("2023-12-08 T 09:25:54.698+08:00");
         df.setTimeZone(tz);
         Date nowAsISO = null;
@@ -395,6 +431,19 @@
 
         if (date == null)
             return "";
+        try {
+            String nowDate = sdfLong.format(date);
+            return nowDate;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    public static String getShortTimeToNull(Date date) {
+
+        if (date == null)
+            return null;
         try {
             String nowDate = sdfLong.format(date);
             return nowDate;
@@ -1325,7 +1374,6 @@
         }
         int nday = caln.get(Calendar.DAY_OF_YEAR);
         days = days + nday - oday;
-
         return days;
     }
 
@@ -2787,9 +2835,10 @@
 
     public static void main(String[] args) {
         try {
-            System.out.println(RandomStringUtils.randomNumeric(3));
-            Date date = getISO8601DateByStr("2023-02-26T08:59:55.206+08:00");
-            System.out.println(getISO8601Timestamp(date));
+            Date date = getISO8601DateByStr("2024-04-15T07:46:36.014+08:00");
+            Date date1 = getISO8601DateByStr("2024-06-14T08:46:36.014+08:00");
+            System.out.println(daysBetweenDates11(date1,date)+1);
+
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -3175,4 +3224,18 @@
         }
         return week;
     }
+
+    /**
+     * 鏃堕棿杞箟甯︽椂鍖�   鍏ュ弬鏍煎紡      2022-09-13T00:53:03.000+00:00
+     * @param timeEscape
+     * @return
+     * @throws ParseException
+     */
+    public static String timeEscape(String timeEscape) throws ParseException {
+        SimpleDateFormat startDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US);
+        SimpleDateFormat startDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String time = startDateFormat1.format(startDateFormat.parse(timeEscape));
+        System.out.println(time);
+        return time;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3