--将自定义的字符串的时间类型转换为日历类型
--调用类
Calendar riskReportTask = Calendar.getInstance();
riskReportTask.add(Calendar.DATE, 1);
taskMgr.dealwith(
new RiskReportTask(),
Utility.getTimer(riskReportTask,"08:30:30").getTime(),
24 * 60 * 60 * 1000
);
--转化类
public static Calendar getTimer(Calendar cal, String timer)
{
String[] segments = timer.split(":");
if (3 != segments.length)
{
throw new RuntimeException("参数格式有误, 应该为: hh:mm:ss");
}
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(segments[0]));
cal.set(Calendar.MINUTE, Integer.parseInt(segments[1]));
cal.set(Calendar.SECOND, Integer.parseInt(segments[2]));
return cal;
}
--添加定时周期任务
public void dealwith(final ITask task, Date firstTime)
{
this.timer = new Timer();
this.timer.schedule(new TimerTask()
{
@Override
public void run()
{
TaskManager.getInstance().dealwith(task);
}
}, firstTime);
}
--添加立即任务
public void dealwith(ITask task)
{
this.taskQueue.putTask(task);
}