Here you can find the source of calendarIterator(final int iterateType, final Calendar startCal, final Calendar endCal)
public static Iterable<Calendar> calendarIterator(final int iterateType, final Calendar startCal, final Calendar endCal)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static Iterable<Calendar> calendarIterator(final int iterateType, final Calendar startCal, final Calendar endCal) { return new Iterable<Calendar>() { final Calendar workCal = (Calendar) startCal.clone(); public Iterator<Calendar> iterator() { return new Iterator<Calendar>() { public boolean hasNext() { return !workCal.after(endCal); }// w ww .j a va 2s . co m public Calendar next() { workCal.add(iterateType, 1); return (Calendar) workCal.clone(); } public void remove() { } }; } }; } /** * A null safe check to whether dt is after dt2. * * @return if dt2 is after dt */ public static boolean after(Date dt, Date dt2) { return !(dt == null || dt2 == null) && dt.after(dt2); } }