Here you can find the source of getBetweenDates(Date fromDate, Date toDate )
public static List<Date> getBetweenDates(Date fromDate, Date toDate )
//package com.java2s; /**/* ww w . j a v a 2 s . c o m*/ * * ACCJava - ACC Java Development Platform * Copyright (c) 2014, AfirSraftGarrier, afirsraftgarrier@qq.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; public class Main { public static List<Date> getBetweenDates(Date fromDate, Date toDate // , int calendarType ) { ArrayList<Date> resultDates = new ArrayList<Date>(); Calendar calendar = Calendar.getInstance(); calendar.setTime(fromDate); Date tmpDate = calendar.getTime(); long endTime = toDate.getTime(); while (tmpDate.before(toDate) || tmpDate.getTime() == endTime) { resultDates.add(calendar.getTime()); calendar.add(Calendar.DAY_OF_YEAR, 1); tmpDate = calendar.getTime(); } Date[] dates = new Date[resultDates.size()]; return resultDates; } }