Java by API/org.apache.commons.logging/StopWatch — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 14:35, 31 мая 2010
new StopWatch()
/*
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.rumons.lang.time.DateUtils;
import org.apache.rumons.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());
}
}
StopWatch: getTime()
/*
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.rumons.lang.time.DateUtils;
import org.apache.rumons.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());
}
}
StopWatch: stop()
/*
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.rumons.lang.time.DateUtils;
import org.apache.rumons.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());
}
}