EDIT: Problem solved, feel free to remove thread.
I have a linked list of assignments, each with a due date. Im looking to iterate through this list and for each assignment due date check if the date is after the first date, therefore finding which is due first.
Below is what i have already. Im finding the first due date and formating the string into a date i can use. Then im going through the list of assignments formatting the due date and checking if it is after the dueDate string i have.
Im getting an error message with if(checkDate.after(dueDate)) saying checkDate is a string not a date. i have tried using the date dateCheck as well but that also doesn't work
public void dueDate() { SimpleDateFormat ValidFormat = new SimpleDateFormat("dd/MM/yyyy"); ListIterator<Assignment> iterator = assignmentList.listIterator(0); String dueDate = iterator.next().getDueDate(); try { Date date = ValidFormat.parse(dueDate); dueDate = ValidFormat.format(date); } catch(ParseException pe) { System.out.println("ParseException" + pe); } while(iterator.hasNext()) { String checkDate = ValidFormat.format(iterator.next().getDueDate()); try { Date dateCheck = ValidFormat.parse(checkDate); checkDate = ValidFormat.format(dateCheck); } catch(ParseException pe) { System.out.println("ParseException" + pe); } if(checkDate.after(dueDate)) dueDate = checkDate; } }