判断当前日期是否在两个日期范围之内

    public static boolean isBetween(LocalDateTime beginTime, LocalDateTime endTime) {
        LocalDateTime now = LocalDateTime.now();
        boolean flag = false;
        if (now.isAfter(beginTime) && now.isBefore(endTime)) {
            flag = true;
        }
        return flag;
    }
    public static void main(String[] args) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String a = "2022-09-06 17:17:57";
        String b = "2022-09-06 18:17:57";
        System.out.println(isBetween(LocalDateTime.parse(a,df),LocalDateTime.parse(b,df)));
    }

 

posted @ 2022-09-07 15:16  _Lawrence  阅读(558)  评论(0编辑  收藏  举报