Here you can find the source of getDatesBetweenTwoDate(Date beginDate, Date endDate)
public static List<Date> getDatesBetweenTwoDate(Date beginDate, Date endDate)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class Main { public static List<Date> getDatesBetweenTwoDate(Date beginDate, Date endDate) {/*from w w w. j ava 2 s . c o m*/ List<Date> dateList = new ArrayList<Date>(); dateList.add(beginDate); Calendar cal = Calendar.getInstance(); cal.setTime(beginDate); boolean bContinue = true; while (bContinue) { cal.add(Calendar.SECOND, 1); if (endDate.after(cal.getTime())) { dateList.add(cal.getTime()); } else { break; } } dateList.add(endDate); return dateList; } }