import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cardvlaue.dao.input_posDAO;
import com.cardvlaue.util.TimerUitl;
public class TimerServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void init(ServletConfig config) throws ServletException {
// Put your code here
super.init();
TimerTest();
}
static void TimerTest(){
Timer timer = new Timer();
//设置执行时间
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);//每天
//定制每天的21:09:00执行, 21600
calendar.set(year, month, day, 0, 00, 00);
Date date = calendar.getTime();
int period = 21600 * 1000;
timer.schedule(new MyTask(), date, period);//在每天的23点59分后执行此任务,以后每隔2秒执行这个MyTask任务.
}
static class MyTask extends java.util.TimerTask{
public void run() {
Examine dao=new Examine();
dao.ExamineBll();
Salse sa = new Salse();
sa.salse();
}
}
}