如何在特定日期和时间运行特定方法? [英] How to run a specific method on a specific date and time?

查看:146
本文介绍了如何在特定日期和时间运行特定方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要强制我的java应用程序在特定的日期和时间执行一些操作。情景如下:

  1-用户设置特定的时间和频率(每天,每个月)
2-系统为请求

3-启动触发器一旦达到预定义的频率和时间
3.1 - 系统执行保存在方法中的所需操作

我发现这个答案,但无法使其工作。



一个例子值得赞赏。

解决方案

是常用的之一。

或简单地使用java ScheduledExecutorService


I need to force my java application to perform a couple of actions on a specific date and time. The scenario is as following:

1- user set a specific time and frequency (every day, every month)
2- system starts a trigger for the request

3- once that pre-defined frequency and time are reached 
 3.1 - system performs the required actions that are kept in a method

I have found this answer but could not make it work.

An example would be appreciated.

解决方案

There are multiple java scheduler frameworks available to do the tasks at your specified time, interval, periodicity. Apache quartz is one of the commonly used ones.

or simply make use of java ScheduledExecutorService

这篇关于如何在特定日期和时间运行特定方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆