reghao 3 лет назад
Родитель
Сommit
f3b305a00d

+ 4 - 10
jdk/src/main/java/cn/reghao/jutil/jdk/converter/DateTimeConverter.java

@@ -105,17 +105,11 @@ public class DateTimeConverter {
         return instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime();
     }
 
-    public static LocalDateTime localDateTime2(String dateTime) {
+    public static LocalDateTime localDateTime2(String dateTime) throws ParseException {
         SimpleDateFormat dateFormat = new SimpleDateFormat(dateTimePattern);
-        try {
-            Date date = dateFormat.parse(dateTime);
-            Instant instant = date.toInstant();
-            return instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime();
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
-
-        return LocalDateTime.now();
+        Date date = dateFormat.parse(dateTime);
+        Instant instant = date.toInstant();
+        return instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime();
     }
 
     /**