|  |  | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.time.*; | 
 |  |  | import java.time.format.DateTimeFormatter; | 
 |  |  | import java.time.temporal.ChronoUnit; | 
 |  |  | import java.time.temporal.TemporalAdjusters; | 
 |  |  | import java.util.*; | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  | import cn.hutool.core.date.DateUnit; | 
 |  |  | import org.apache.commons.lang3.RandomStringUtils; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  |  | 
 |  |  | 
 |  |  |             return new Timestamp(System.currentTimeMillis()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     public static Date getDateFromString2(String strDate) { | 
 |  |  |         if (StringUtils.isEmpty(strDate)) { | 
 |  |  |           return  null; | 
 |  |  |         } | 
 |  |  |         try { | 
 |  |  |             return sdfLongTimePlus.parse(strDate); | 
 |  |  |         } catch (Exception ex) { | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     // ----------------------------------------------------------------------- | 
 |  |  | 
 |  |  |         try { | 
 |  |  | //            Date date = getISO8601DateByStr("2024-04-15T07:46:36.014+08:00"); | 
 |  |  | //            Date date1 = getISO8601DateByStr("2024-06-14T08:46:36.014+08:00"); | 
 |  |  |             System.out.println(DateUtil.afterMinutesDate(-5)); | 
 |  |  | //            System.out.println(DateUtil.afterMinutesDate(-5)); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             Date startTime = DateUtil.StringToDate("2024-05-01 08:00:00" ,"yyyy-MM-dd HH:mm:ss"); | 
 |  |  |             Date endTime = DateUtil.StringToDate("2024-05-01 17:00:00" ,"yyyy-MM-dd HH:mm:ss"); | 
 |  |  |             Long intervalTime = 35L; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             DateUtil.checkDateInterval( startTime.toInstant() | 
 |  |  |                     .atZone(ZoneId.systemDefault()) | 
 |  |  |                     .toLocalDateTime(), endTime.toInstant() | 
 |  |  |                     .atZone(ZoneId.systemDefault()) | 
 |  |  |                     .toLocalDateTime(),intervalTime); | 
 |  |  |  | 
 |  |  |         } catch (Exception ex) { | 
 |  |  |             ex.printStackTrace(); | 
 |  |  | 
 |  |  |         System.out.println(time); | 
 |  |  |         return time; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public static List<LocalDateTime> checkDateInterval(LocalDateTime localStartTime,LocalDateTime localEndTime,Long interval){ | 
 |  |  |         List<LocalDateTime> segments = new ArrayList<>(); | 
 |  |  |         LocalDateTime current = localStartTime; | 
 |  |  |         while (current.isBefore(localEndTime)) { | 
 |  |  |             segments.add(current); | 
 |  |  |             current = current.plus(interval, ChronoUnit.MINUTES); | 
 |  |  |         } | 
 |  |  |         return segments; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |