获取某天时间的起止日期
hutool工具类:需要导入hutool的依赖
工具类:DateUtil
String datestr ="2021-12-01 22:25:30"; Date date =DateUtil.parse(datestr); //一天的开始,结果:2021-12-01 00:00:00 Date beginOfDay=DateUtil.beginOfDay(date); //一天的结束,结果 :2021-12-01 23:59:59 Date endOfDay=DateUtil.endOfDay(date);

第二种方法
Date taskEndTime = integrationTaskDTO.getTaskEndTime();
LocalDateTime localDateTime =
LocalDateTime.ofInstant(Instant.ofEpochMilli(taskEndTime.getTime()), ZoneId.systemDefault());
LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX);
Date from = Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());

浙公网安备 33010602011771号