获取两个日期之间的日期

 1 public List<String> getBetweenDateStr(Date start, Date end){
 2         if(start==null || end==null)return null;
 3         List<String> list=new ArrayList<String>();
 4         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
 5         String endstr = sdf.format(end);
 6         boolean go=true;
 7         Calendar ca=Calendar.getInstance();
 8         ca.setTime(start);
 9         while(go){
10             ca.add(Calendar.DAY_OF_MONTH, 1);
11             String startstr = sdf.format(ca.getTime());
12             list.add(startstr);
13             if(startstr.equals(endstr)){
14                go=false;15             }
16         }
17         return list;
18     }

 

posted @ 2017-04-24 12:07  天涯已可  阅读(344)  评论(0编辑  收藏  举报