import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.StopWatch;
public class MainClass {
public static void main(String[] args) {
StopWatch stWatch = new StopWatch();
//Start StopWatch
stWatch.start();
//Get iterator for all days in a week starting Monday
Iterator itr = DateUtils.iterator(new Date(),
DateUtils.RANGE_WEEK_MONDAY);
while (itr.hasNext()) {
Calendar gCal = (Calendar) itr.next();
System.out.println(gCal.getTime());
}
//Stop StopWatch
stWatch.stop();
System.out.println("Time Taken >>" + stWatch.getTime());
}
}
Mon May 07 00:00:00 PDT 2007
Tue May 08 00:00:00 PDT 2007
Wed May 09 00:00:00 PDT 2007
Thu May 10 00:00:00 PDT 2007
Fri May 11 00:00:00 PDT 2007
Sat May 12 00:00:00 PDT 2007
Sun May 13 00:00:00 PDT 2007
Time Taken >>32
Download: CommonLangDateUtils.iterator.zip( 199 k)