Currently I am trying to read and write the futureMeetingArray and pastMeetingArray and then later call on them in the getMeetingListOn method. This method should find any meetings with the same date and add them to an array and return that array. However, at the moment it is not finding these (so far I am only testing it on the futureMeetingsArray). I have also included the addFutureMeeting method to illustrate how I have set about adding to and then serializing the futureArrayList. Each FutureMeeting object has a global Calendar variable, which I am calling on through getters and setters. I can provide the code for this if it makes it clearer.
If anyone could suggest a reason why it is not finding the dates, I would be grateful.
public class ContactManagerImpl implements ContactManager {
Calendar date;
List<Meeting> futureMeetingArray = new ArrayList<Meeting>();
List<PastMeetingImpl> pastMeetingArray = new ArrayList<PastMeetingImpl>();
List<Contact> allContacts = new ArrayList<Contact>();
@Override
public int addFutureMeeting(Set<Contact> contacts, Calendar date) {
readSerializedData();
int ID = (int)(Math.random()*500 + 1000);
FutureMeetingImpl fm = new FutureMeetingImpl(contacts, ID, date);
futureMeetingArray.add(fm);
makeNewFolder();
try {
FileOutputStream fileOut = new FileOutputStream("./serialized/newfuturemeeting1.out");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(futureMeetingArray); //This is so I can use later methods down where you need to get specific meetings in list form
out.close();
fileOut.close();
}catch(IOException i) {
i.printStackTrace();
}
contactAdder(contacts);
return ID;
}
@Override
public List<Meeting> getMeetingListOn(Calendar date) {
readSerializedData();
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
String formatted = format1.format(date.getTime());
List<Meeting> meetings = new ArrayList<Meeting>();
Meeting currentMeeting = futureMeetingArray.get(0);
if(futureMeetingArray.size() > 0){
for(int x = 0; x < futureMeetingArray.size(); x++){
currentMeeting = futureMeetingArray.get(x);
Calendar currentMeetingsDate = currentMeeting.getDate();
System.out.println("s");
if(currentMeetingsDate == date){
System.out.println("Adding future");
meetings.add(currentMeeting);
}
}
}
for (int p = 0; p < pastMeetingArray.size(); p++){
Meeting currentMeetingPast = new PastMeetingImpl();
SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd");
String formatted3 = format3.format(currentMeetingPast.getDate());
System.out.println(formatted3);
if(formatted3 == formatted){
System.out.println("Adding future");
meetings.add(currentMeetingPast);
}
}
for(int y = 0; y < meetings.size(); y++){
Meeting meetingPrint = meetings.get(y);
System.out.println("Your list of meetings include meeting IDs: " + meetingPrint.getId());
}
return meetings;
}
}