[英]Starting a task in a certain time
我使用以下代碼每5分鍾執行一次任務。
this.timer.schedule(new Send(), new Date(), TEN_SECONDS*6*5);
我的問題是,如何在這種時間開始我的任務:xx:00,xx:05,xx:10,xx:15 - 在5分鍾的跳躍中,所以我想從最近的5開始我的任務分鍾跳。
你可以使用石英。
它是開源的,具有類似cron的功能。
http://quartz-scheduler.org/documentation/quartz-2.1.x/examples/Example3
這不是那么難,非常簡單的數學。
d1.setMinutes(d1.getMinutes() + 5 - d1.getMinutes()%5);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.