zoukankan      html  css  js  c++  java
  • 获取两日期之前集合并转为String类型的集合

     1 /**
     2      * 获取两个日期之间的日期
     3      *
     4      * @param start 开始日期
     5      * @param end   结束日期
     6      * @return 日期集合
     7      */
     8     private static List<Date> getBetweenDates(Date start, Date end) {
     9         List<Date> result = new ArrayList<>();
    10         result.add(start);
    11         Calendar tempStart = Calendar.getInstance();
    12         tempStart.setTime(start);
    13         tempStart.add(Calendar.DAY_OF_YEAR, 1);
    14 
    15         Calendar tempEnd = Calendar.getInstance();
    16         tempEnd.setTime(end);
    17         while (tempStart.before(tempEnd)) {
    18             result.add(tempStart.getTime());
    19             tempStart.add(Calendar.DAY_OF_YEAR, 1);
    20         }
    21         if (start.getTime() != end.getTime()) {
    22             result.add(end);
    23         }
    24         return result;
    25     }

      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    List<String> strDateList = dateList.stream().map(simpleDateFormat::format).collect(Collectors.toList()); 

  • 相关阅读:
    7月27日
    7月26日
    7月25日
    7月24日
    UI基础 选项卡
    UI基础 手势
    UI基础 小球拖拽
    UI基础 事件
    UI基础 自定义视图
    UI基础 视图控制器
  • 原文地址:https://www.cnblogs.com/wang-yaz/p/10862920.html
Copyright © 2011-2022 走看看