|
@@ -2,6 +2,9 @@ package com.ywt.biz.common.util;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.GregorianCalendar;
|
|
@@ -237,4 +240,20 @@ public class DateUtil {
|
|
|
return sdf.format(date);
|
|
|
}
|
|
|
|
|
|
+ public static LocalDate convertToLocalDate(Date date) {
|
|
|
+ Instant instant = date.toInstant();
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
+ return instant.atZone(zoneId).toLocalDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将时间戮转换成 LocalDate 类型
|
|
|
+ *
|
|
|
+ * @param timestamp 时间戮
|
|
|
+ * @return 日期类型 LocalDate
|
|
|
+ */
|
|
|
+ public static LocalDate convertToLocalDate(long timestamp) {
|
|
|
+ return Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ }
|
|
|
+
|
|
|
}
|