程序为什么没有执行啊!
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
public class TimerTask { public void time() {
String s = "2007-03-10 11:00:00";
SimpleDateFormat si = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
try {
date = si.parse(s);
Timer timer = new Timer();
timer.schedule(new Task(), date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args){
// TODO Auto-generated method stub
TimerTask tt = new TimerTask();
tt.time();
}}
import java.util.TimerTask;;
public class Task extends TimerTask{
public void run(){
System.out.println("任务执行中---");
}
}
是不是这个地方,timer.schedule(new Task(), date);
我转换日期格式的时候的date的问题?
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
public class TimerTask { public void time() {
String s = "2007-03-10 11:00:00";
SimpleDateFormat si = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
try {
date = si.parse(s);
Timer timer = new Timer();
timer.schedule(new Task(), date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args){
// TODO Auto-generated method stub
TimerTask tt = new TimerTask();
tt.time();
}}
import java.util.TimerTask;;
public class Task extends TimerTask{
public void run(){
System.out.println("任务执行中---");
}
}
是不是这个地方,timer.schedule(new Task(), date);
我转换日期格式的时候的date的问题?
今天是9号,时间还没有到!!!