public List<Appointment> getAppointmentsBetweenDates(CalendarDate start, CalendarDate end) { // given a start and end date, returns a list of appointments that recur between these dates int startID = CalendarDate.getDateID(start); int endID = CalendarDate.getDateID(end); List<Appointment> aps = new ArrayList<Appointment>(); Appointment ap; ListIterator<Appointment> it = appList.listIterator(); int ap_ID; while (it.hasNext()) { ap = (Appointment) it.next(); List<CalendarDate> cd = ap.getRecurrenceDates(startID, endID); if (cd.size() > 0) { aps.add(ap); } } return aps; }
public boolean saveCalendar(String fileName) { // saves the calendar to the file of given file name. FileOutputStream out; PrintStream p; try { out = new FileOutputStream(fileName); p = new PrintStream(out); Appointment ap; ListIterator<Appointment> it = appList.listIterator(); while (it.hasNext()) { ap = (Appointment) it.next(); p.println("<"); p.println(ap.getID()); p.println(CalendarDate.getDateID(ap.date)); p.println(ap.start_time.hr); p.println(ap.start_time.min); p.println(ap.end_time.hr); p.println(ap.end_time.min); p.println(ap.description); p.println(ap.location); p.println(ap.category); p.println(Appointment.IntFromRecurrence(ap.recur)); p.println(ap.reminder); p.println(">"); // ap.printAppointment(); // System.out.println("\n"); } } catch (Exception e) { System.err.println("Error writing to file"); return false; } return true; }