Browse Source

修改 格式化日期数据

andy 1 year ago
parent
commit
d83abccfab
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/main/java/com/scbfkj/uni/library/DataFormatUtil.java

+ 11 - 2
src/main/java/com/scbfkj/uni/library/DataFormatUtil.java

@@ -78,7 +78,7 @@ public final class DataFormatUtil {
         } else if (dateObj instanceof Date date) {
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:ss");
             String formatDate = simpleDateFormat.format(date);
-            return LocalDate.parse(formatDate);
+            return LocalDate.parse(formatDate.replace(" ","T"));
         }  else {
             return null;
         }
@@ -92,7 +92,7 @@ public final class DataFormatUtil {
         } else if (dateTimeObj instanceof Date date) {
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:ss");
             String formatDate = simpleDateFormat.format(date);
-            return LocalDateTime.parse(formatDate);
+            return LocalDateTime.parse(formatDate.replace(" ","T"));
         } else {
             return null;
         }
@@ -263,4 +263,13 @@ public final class DataFormatUtil {
             return data;
         }).toList();
     }
+
+    public static boolean isJson(String data) {
+        try{
+            JsonNode jsonNode = getObjectMapper().readTree(data);
+            return true;
+        }catch (Exception e){
+            return false;
+        }
+    }
 }