java8获取当天00:00:00 23:59:59 时间戳

*获取当天零点和23点时间戳 2021-07-08
–获取当前时间戳 —1625714358823
System.out.println(LocalDateTime.now().toInstant(ZoneOffset.of(“+8”)).toEpochMilli());
—获取当天零点时间戳 --1625673600000
System.out.println(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).toInstant(ZoneOffset.of(“+8”)).toEpochMilli());-- -
----获取当天23:59:59时间戳 1625759999999
System.out.println(LocalDateTime.of(LocalDate.now(), LocalTime.MAX).toInstant(ZoneOffset.of(“+8”)).toEpochMilli());
—获取当天23:59:59时间戳 1625759999000
System.out.println(LocalDateTime.of(LocalDate.now(), LocalTime.of(23,59,59)).toInstant(ZoneOffset.of(“+8”)).toEpochMilli());

获取三天前的最大时间 和最小时间
LocalDateTime dateTime = LocalDateTime.now();
LocalDateTime minTime = dateTime.minusDays(3).with(LocalTime.MIN);
long minTimes = minTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli() / 1000;
LocalDateTime maxTime = dateTime.minusDays(3).with(LocalTime.MAX);
long maxTimes = maxTime.toInstant(ZoneOffset.ofHours(8)).toEpochMilli() / 1000;

你可能感兴趣的:(java)