1 19 20 package com.jtheory.jdring; 21 import java.util.Calendar ; 22 import java.util.Date ; 23 import java.util.List ; 24 import java.util.Iterator ; 25 26 import com.jtheory.jdring.*; 27 28 29 35 public class Test { 36 public static void main(String [] args) throws Exception { 37 38 AlarmManager mgr = new AlarmManager(); 39 40 long current = System.currentTimeMillis(); 41 System.out.println("Current date is " + new Date (current)); 42 43 AlarmListener listener = new AlarmListener() { 44 public void handleAlarm(AlarmEntry entry) { 45 System.out.println("\u0007fixed date alarm : " + entry); 46 } 47 }; 48 49 104 105 mgr.addAlarm("ComplexCron2",new int[]{16,17,18}, new int[]{16}, new int[]{-1}, new int[]{-1}, new int[]{Calendar.SUNDAY}, -1, new AlarmListener() { 107 public void handleAlarm(AlarmEntry entry) { 108 System.out.println("\u0007Cron complex2 (" + new Date () + ")"); 109 } 110 }); 111 112 148 149 System.out.println("Here are the registered alarms: "); 150 System.out.println("----------------------------"); 151 List list = mgr.getAllAlarms(); 152 for(Iterator it = list.iterator(); it.hasNext();) { 153 System.out.println("- " + it.next()); 154 } 155 System.out.println("----------------------------"); 156 } 157 } 158 159 | Popular Tags |