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

     private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    public static List<String> splitDateList(Date startDate, Date endDate) {
            List<String> listDate = new ArrayList<>();
            try {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(startDate);
                while (calendar.getTime().before(endDate) || calendar.getTime().equals(endDate)) {
                    listDate.add(dateFormat.format(calendar.getTime()));
                    calendar.add(Calendar.DAY_OF_MONTH, 1);
                }
                return listDate;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return listDate;
        }
    -----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------ (蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)
  • 相关阅读:
    Elasticsearch的RESTful API使用
    Elasticsearch简介与安装
    安装MySQL
    数据处理与文件查找,压缩与解压
    Linux网络设置
    文件与文件夹
    基本命令
    se
    爬虫请求库之requests
    redis五种数据类型
  • 原文地址:https://www.cnblogs.com/pxblog/p/15062596.html
Copyright © 2011-2022 走看看