Here you can find the source of getBetweenTwoDayCalender(String startDay, String endDay)
public static List<String> getBetweenTwoDayCalender(String startDay, String endDay)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Main { public static List<String> getBetweenTwoDayCalender(String startDay, String endDay) { List<String> list = new ArrayList<String>(); if (startDay == null || startDay.equals("")) { return null; }//from w w w.j a v a2 s.co m if (endDay == null || endDay.equals("")) { return null; } SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); try { Date startD = myFormatter.parse(startDay); Date endD = myFormatter.parse(endDay); long day = (endD.getTime() - startD.getTime()) / (24 * 60 * 60 * 1000); long dayMill = 24 * 60 * 60 * 1000; int d = Integer.parseInt(String.valueOf(day)); String updateTime; long longTime; for (int i = 0; i <= d; i++) { longTime = startD.getTime() + dayMill * i; updateTime = myFormatter.format(new Date(longTime)); list.add(updateTime); } } catch (ParseException e) { e.printStackTrace(); } return list; } }