package seedu.ezdo.commons.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import seedu.ezdo.model.todo.ReadOnlyTask;

/*
 * Checks for dates
 */
public class DateUtil {
    public static boolean isTaskDateValid(ReadOnlyTask task) throws ParseException {
        assert task != null;
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy H:mm");
        Date startDate = df.parse(task.getStartDate().toString());
        Date dueDate = df.parse(task.getDueDate().toString());
        if (task.getStartDate().toString().equals("") || task.getDueDate().toString().equals("")) {
            return true;
        }
        return (startDate.compareTo(dueDate) < 0);
    }


    /**
     * Compares two dates strings. Both strings must be in the format dd/MM/yyyy hh:mm.
     * Empty strings are considered to be of lower value than non-empty strings.
     * @return an int representing the comparison result of the two date strings.
     * @throws ParseException if any of the date strings cannot be parsed.
     */
    public static int compareDateStrings(String dateString1, String dateString2) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm");
        Date date1 = null;
        Date date2 = null;

        // empty dates are considered lower in value so that they show at the bottom of the list
        if (dateString1.isEmpty() && dateString2.isEmpty()) {
            return 0;
        } else if (dateString1.isEmpty()) {
            return 1;
        } else if (dateString2.isEmpty()) {
            return -1;
        }

        try {
            date1 = dateFormat.parse(dateString1);
            date2 = dateFormat.parse(dateString2);
        } catch (ParseException pe) {
            assert false : "The date format should not be invalid.";
        }

        return date1.compareTo(date2);
    }
}

@@ -320,32 +320,165 @@
 t task != null;%0A
+        if (task.getStartDate().toString().isEmpty() %7C%7C task.getDueDate().toString().isEmpty()) %7B%0A            return true;%0A        %7D%0A
         SimpleDa

Move if block up so no need waste unnecessary operations