DateUtils: iterator(Date arg0, int arg1) : DateUtils « org.apache.commons.logging « Java by API






DateUtils: iterator(Date arg0, int arg1)

/*
Mon Jun 05 00:00:00 PDT 2006
Tue Jun 06 00:00:00 PDT 2006
Wed Jun 07 00:00:00 PDT 2006
Thu Jun 08 00:00:00 PDT 2006
Fri Jun 09 00:00:00 PDT 2006
Sat Jun 10 00:00:00 PDT 2006
Sun Jun 11 00:00:00 PDT 2006
Time Taken >>47

 * */

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 TimeTrial {
  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());

  }
}

           
       








Apache-Common-Lang.zip( 248 k)

Related examples in the same category

1.DateUtils.RANGE_WEEK_MONDAY