public class EmailSendListener implements ServletContextListener{

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //创建一个计时器
        Timer timer = new Timer();
        //日期对象
        Calendar calendar = Calendar.getInstance();
        calendar.set(2015, 3, 10, 11, 21, 40);
        //schedule  执行任务    时间
        timer.schedule(new TimerTask() {
            
            @Override
            public void run() {
                System.out.println("开始发邮件了--------------------------");
            }
        }, calendar.getTime());
        
    }

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2023-04-10
  • 2022-01-26
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2021-08-31
  • 2021-05-18
  • 2022-03-06
相关资源
相似解决方案