1 17 package org.alfresco.util; 18 19 import java.text.ParseException ; 20 import java.util.Calendar ; 21 import java.util.GregorianCalendar ; 22 23 import org.springframework.scheduling.quartz.SimpleTriggerBean; 24 25 35 public class TriggerBean extends SimpleTriggerBean 36 { 37 private static final long serialVersionUID = 6526305743899044951L; 38 39 private int hour = 0; 40 private int minute = 0; 41 42 45 public void setHour(int hour) 46 { 47 this.hour = hour; 48 } 49 50 53 public void setMinute(int minute) 54 { 55 this.minute = minute; 56 } 57 58 @Override 59 public void afterPropertiesSet() throws ParseException 60 { 61 Calendar calendar = new GregorianCalendar (); 63 calendar.setLenient(true); 64 int year = calendar.get(Calendar.YEAR); 65 int month = calendar.get(Calendar.MONTH); 66 int day = calendar.get(Calendar.DAY_OF_MONTH); 67 int nowHour = calendar.get(Calendar.HOUR_OF_DAY); 68 int nowMinute = calendar.get(Calendar.MINUTE); 69 70 if (hour < nowHour || (hour == nowHour && minute <= nowMinute)) 72 { 73 calendar.set(Calendar.DAY_OF_MONTH, day + 1); 74 } 75 calendar.set(Calendar.HOUR_OF_DAY, hour); 77 calendar.set(Calendar.MINUTE, minute); 78 setStartTime(calendar.getTime()); 80 81 super.afterPropertiesSet(); 83 } 84 } 85 | Popular Tags |