Here you can find the source of getBetweenDate(String d1, String d2)
public static GregorianCalendar[] getBetweenDate(String d1, String d2)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static GregorianCalendar[] getBetweenDate(String d1, String d2) { Vector<GregorianCalendar> v = new Vector<GregorianCalendar>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); GregorianCalendar gc1 = new GregorianCalendar(), gc2 = new GregorianCalendar(); try {//from w w w.j ava 2 s. c om gc1.setTime(sdf.parse(d1)); gc2.setTime(sdf.parse(d2)); do { GregorianCalendar gc3 = (GregorianCalendar) gc1.clone(); v.add(gc3); gc1.add(Calendar.DAY_OF_MONTH, 1); } while (!gc1.after(gc2)); } catch (Exception e) { e.printStackTrace(); } return v.toArray(new GregorianCalendar[v.size()]); } }