LocalDateTime 日期
//当天的零点 wrapper.ge(PcTodayQuotation::getCreateTime,LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MIN)); //当天的最后时间 wrapper.le(PcTodayQuotation::getCreateTime,LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MAX));
LocalDateTime curDateTime = LocalDateTime.now(); curDateTime.plusDays(-1);
curDateTime.minusDays(i).toLocalDate()
//当天的零点 System.out.println("当天的零点: "+LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MIN)); //当天的最后时间 System.out.println("当天的最后时间: "+LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MAX)); //i天前的零点 System.out.println("1天前的零点: "+LocalDateTime.of(LocalDateTime.now().minusDays(1).toLocalDate(), LocalTime.MIN)); //i天前的最后时间 System.out.println("1天前的最后时间: "+LocalDateTime.of(LocalDateTime.now().minusDays(1).toLocalDate(), LocalTime.MAX)); //1月前的零点 System.out.println("1月前的零点: "+ LocalDateTime.of(LocalDateTime.now().minusMonths(1).withDayOfMonth(1).toLocalDate(), LocalTime.MIN)); //i天前的最后时间 System.out.println("1月前的最后时间: "+ LocalDateTime.of(LocalDateTime.now().minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).toLocalDate(), LocalTime.MAX)); //1年前的零点 System.out.println("1年前的零点: "+LocalDateTime.of(LocalDateTime.now().minusYears(1).withDayOfYear(1).toLocalDate(), LocalTime.MIN)); //i年前的最后时间 System.out.println("1年前的最后时间: "+LocalDateTime.of(LocalDateTime.now().minusYears(1).with(TemporalAdjusters.lastDayOfYear()).toLocalDate(), LocalTime.MAX));
LocalDateTime localDateTime = LocalDateTime.now(); Month month = localDateTime.getMonth(); Month firstMonthOfQuarter = month.firstMonthOfQuarter(); Month endMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2); LocalDate localDate_start = LocalDate.of(localDateTime.getYear(), firstMonthOfQuarter, 1); LocalDate localDate_end = LocalDate.of(localDateTime.getYear(), endMonthOfQuarter, 1); //1季前的零点 System.out.println("1季前的零点: "+ LocalDateTime.of(localDate_start.minusMonths(1*3).withDayOfMonth(1), LocalTime.MIN)); //i季前的最后时间 System.out.println("1季前的最后时间: "+ LocalDateTime.of(localDate_end.minusMonths(1*3).with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX));