
NextReminder
By:
ace on
Jan 24th, 2010 | syntax:
None | size: 0.78 KB | hits: 11 | expires: Never
public RCalendar getNextReminderDate(String doctorID,
RCalendar previousReminderDate) {
RCalendar nextR = new RCalendar(previousReminderDate);
for(NextReminder nr : reminderList){
if(doctorID.equals(nr.doctorID)){
//snip//
//get the integer value for the day of the week
int dayOfWeek = dayToInt(nr.unit);
//if the DAY_OF_WEEK is not already = the dayOfWeek, set it.
if(nextR.get(Calendar.DAY_OF_WEEK) != dayOfWeek){nextR.set(Calendar.DAY_OF_WEEK, dayOfWeek);}
//nr.m = 0 means "every", so "every week" or "every 2nd week" etc.
if(nr.m == 0){nextR.add(Calendar.WEEK_OF_MONTH, nr.n); return nextR;}
//otherwise nr.m indicates how many months between reminders
nextR.add(Calendar.MONTH, nr.m);
nextR.set(Calendar.WEEK_OF_MONTH, nr.n);
}