| | |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.DayOfWeek; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoField; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | |
| | | |
| | | return dateString; |
| | | } |
| | | |
| | | /** |
| | | * Date与LocalDateTime互相转换的工具方法 |
| | | * |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static LocalDateTime convertToLocalDateTime(Date date) { |
| | | if (date == null) { |
| | | return null; |
| | | } |
| | | return Instant.ofEpochMilli(date.getTime()) |
| | | .atZone(ZoneId.systemDefault()) |
| | | .toLocalDateTime(); |
| | | } |
| | | |
| | | /** |
| | | * Date与LocalDateTime互相转换的工具方法 |
| | | * |
| | | * @param localDateTime |
| | | * @return |
| | | */ |
| | | public static Date convertToDate(LocalDateTime localDateTime) { |
| | | if (localDateTime == null) { |
| | | return null; |
| | | } |
| | | return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | } |