测试AlarmClock类 本帖最后由 sky123123 于 2010-03-25 17:30:56 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.text.SimpleDateFormat;import java.util.Date;import org.tiling.scheduling.Scheduler;import org.tiling.scheduling.SchedulerTask;import org.tiling.scheduling.examples.iterators.DailyIterator;public class AlarmClock { private final Scheduler scheduler = new Scheduler();//调度器 private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss.SSS"); private int hourOfDay, minute, second;//每天触发的时间点 public AlarmClock(int hourOfDay, int minute, int second) { this.hourOfDay = hourOfDay; this.minute = minute; this.second = second; } public void start() { scheduler.schedule(new SchedulerTask() { public void run() { soundAlarm(); new AlarmClock(hourOfDay,minute,second+1).start(); } private void soundAlarm() { System.out.println("Wake up! " + "It's " + dateFormat.format(new Date())); // Start a new thread to sound an alarm } }, new DailyIterator(hourOfDay, minute, second));//通过迭代器模式迭代遍历得到后面一系列的时间点 } public static void main(String[] args) { AlarmClock alarmClock = new AlarmClock(18, 30, 50); alarmClock.start(); }} 哦,这样啊,我一般都是使用 Quartz 这个调度框架,挺好用的,你也可以去看看。 myeclipse 9.0 打开class后缀文件时出错 怎么解决啊 难道只能打开java后缀的吗 请问set JAVA_OPTS的各项参数是什么意思? 关于枚举问题! 编译java过种中出现问题,请专家来看看 乘法运算问题 Java 中import了不使用的package会影响编译或执行效率吗? applet 和*.jar不能运行的错误?(在线等待) 大家帮帮忙!!! char w[i]=='' 谁有Sun最新提供的j2sdkee-1_3_1-win.exe? 各位大侠帮我看看哪错了!!! 是强人的帮小弟看一下程序,详细分析给我听,好嘛!
import java.text.SimpleDateFormat;import java.util.Date;import org.tiling.scheduling.Scheduler;
import org.tiling.scheduling.SchedulerTask;
import org.tiling.scheduling.examples.iterators.DailyIterator;public class AlarmClock
{ private final Scheduler scheduler = new Scheduler();//调度器
private final SimpleDateFormat dateFormat =
new SimpleDateFormat("dd MMM yyyy HH:mm:ss.SSS");
private int hourOfDay, minute, second;//每天触发的时间点 public AlarmClock(int hourOfDay, int minute, int second)
{
this.hourOfDay = hourOfDay;
this.minute = minute;
this.second = second;
} public void start()
{
scheduler.schedule(new SchedulerTask()
{
public void run()
{
soundAlarm();
new AlarmClock(hourOfDay,minute,second+1).start();
}
private void soundAlarm()
{
System.out.println("Wake up! " +
"It's " + dateFormat.format(new Date()));
// Start a new thread to sound an alarm
}
}, new DailyIterator(hourOfDay, minute, second));//通过迭代器模式迭代遍历得到后面一系列的时间点
} public static void main(String[] args)
{
AlarmClock alarmClock = new AlarmClock(18, 30, 50);
alarmClock.start();
}
}