package com.yang.stati;
import java.util.TimerTask;
public class TimerTaskTest extends TimerTask{
@Override public void run() {
System.out.println("时间到!"); }
}
package com.yang.stati;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class TimerTest {
private Timer time=new Timer();
public void execute(
TimerTaskTest timeto,Date date){
System.out.println(time);
time.schedule(timeto, date);
} }
package com.yang.stati;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimerTask;
public class Clock {
/** * @param args *
@throws ParseException */
public static void main(String[] args) throws ParseException {
TimerTest tt=new TimerTest();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy/M/d/H/m");
tt.execute(new TimerTaskTest(), sdf.parse("2008/7/6/16/34"));
}
}