dowload di sini
http://www.ibm.com/developerworks/java/library/j-schedule.html#download
berikut kodinya
package org.tiling.scheduling.examples;hasilnya
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 final 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();
}
private void soundAlarm() {
System.out.println("Bangun - bangun! " +
"Ini udah jam " + 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(7, 0, 0);
alarmClock.start();
}
}
Bangun - bangun! Ini udah jam 24 Aug 2003 07:00:00.023dalam hal ini aplikasi java yang kita buat .. akan menulikaskan pesan tersebut setiap pukul 07:00:00 setipa hari
Bangun - bangun! Ini udah jam 25 Aug 2003 07:00:00.001
Bangun - bangun! Ini udah jam 26 Aug 2003 07:00:00.058
Bangun - bangun! Ini udah jam 27 Aug 2003 07:00:00.015
Bangun - bangun! Ini udah jam 28 Aug 2003 07:00:00.002
...
demikan terimakasih :d
Tidak ada komentar:
Posting Komentar