LocalDate或者LocalDateTime判断是否在本月之内

//判断时间是否在本月之内
public static boolean isInThisMonth(LocalDateTime time) {
    LocalDate localDate = time.toLocalDate();
    LocalDate now = LocalDate.now();
    return localDate.isAfter(now.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth())) &&
            localDate.isBefore(now.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()));
}

猜你喜欢

转载自blog.csdn.net/u013282737/article/details/104778445