|
|
|
@ -2,6 +2,10 @@ package cn.chjyj.szwh.utils; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.Instant; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneId; |
|
|
|
import java.time.ZonedDateTime; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
@ -67,4 +71,19 @@ public class DateUtils { |
|
|
|
return mon.getTime(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 日期本地化 |
|
|
|
* note:Date对象表示特定的日期和时间,而LocalDate(Java8)对象只包含没有任何时间信息的日期。 |
|
|
|
* @param date |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static LocalDateTime convertDateToLocalDateTime(Date date){ |
|
|
|
// 系统时区
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
Instant instant = date.toInstant(); |
|
|
|
// atZone()方法返回在指定时区从此Instant生成的ZonedDateTime。
|
|
|
|
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime(); |
|
|
|
return localDateTime; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|