zoukankan      html  css  js  c++  java
  • Java 获取两个日期之间的日期

    1、前期需求,两个日期,startDate和endDate,然后获取到两个日期之间的日期

    /**
     * 获取两个日期之间的日期
     * @param start 开始日期
     * @param end 结束日期
     * @return 日期集合
     */
    private List<Date> getBetweenDates(Date start, Date end) {
        List<Date> result = new ArrayList<Date>();
        Calendar tempStart = Calendar.getInstance();
        tempStart.setTime(start);
        tempStart.add(Calendar.DAY_OF_YEAR, 1);
        
        Calendar tempEnd = Calendar.getInstance();
        tempEnd.setTime(end);
        while (tempStart.before(tempEnd)) {
            result.add(tempStart.getTime());
            tempStart.add(Calendar.DAY_OF_YEAR, 1);
        }
        return result;
    }

    您的资助是我最大的动力!
    金额随意,欢迎来赏!

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的推荐按钮。
    如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的关注我

    如果,想给予我更多的鼓励,求打

    欢迎大家关注我的个人博客 Lycos | 小站 !由于最近没时间处理,原域名http://www.liuyuchuan.com暂时停止使用

  • 相关阅读:
    CF1580B Mathematics Curriculum
    [机房测试]变异大老鼠
    http_缓存
    UDP_概述
    记录: webAssembly 延申
    Event
    NetWork_timeLine
    基于Typora的Latex代码书写并移植到word中
    ZooKeeper学习总结
    HBase学习总结
  • 原文地址:https://www.cnblogs.com/yuchuan/p/java_date_cal.html
Copyright © 2011-2022 走看看