package seedu.ezdo.model.todo;

import com.joestelmach.natty.Parser;

/**
 * Represents the date associated with tasks.
 */
public abstract class TaskDate {

    public final String value;

    public static final String TASKDATE_VALIDATION_REGEX =
        "^$|([12][0-9]|3[01]|0?[1-9])/(0?[1-9]|1[012])/((?:19|20)\\d\\d)";

    public TaskDate(String taskDate) {
    	Parser parser = new Parser();
        this.value = parser.parse(taskDate).get(0).getDates().get(0).toString();
    }

    @Override
    public String toString() {
        return value;
    }

    @Override
    public boolean equals(Object other) {
        return other == this // short circuit if same object
                || (other instanceof TaskDate // instanceof handles nulls
                && this.value.equals(((TaskDate) other).value)); // state check
    }

    @Override
    public int hashCode() {
        return value.hashCode();
    }

    /**
     * Returns true if a given string is a valid task date.
     */
    public static boolean isValidTaskDate(String test) {
        return test.matches(TASKDATE_VALIDATION_REGEX);
    }
}

@@ -25,16 +25,171 @@
 .todo;%0A%0A
+import java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.List;%0A%0Aimport com.joestelmach.natty.DateGroup;%0A
 import c
@@ -217,16 +217,16 @@
 Parser;%0A
-
 %0A/**%0A * 
@@ -516,121 +516,2265 @@
 ) %7B%0A
+%0A
     
-%09Parser parser = new Parser();%0A        this.value = parser.parse(taskDate).get(0).getDates().get(0).toString(
+    if (isValidTaskDate(taskDate)) %7B%0A            // Format input string to suit Natty dependency%0A            String formattedInitialTaskDate = changeToNattyDateFormat(taskDate);%0A%0A            // Use Natty dependency to manipulate date input%0A            Date parsedTaskDate = parseNatty(formattedInitialTaskDate);%0A%0A            // Format parsed date to suit the regex%0A            String formattedFinalTaskDate = changeToUserDateFormat(parsedTaskDate);%0A%0A            this.value = formattedFinalTaskDate;%0A%0A        %7D else %7B%0A            this.value = %22%22;%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * Uses Natty dependency (natural language date parser) to manipulate date%0A     * input in String.%0A     * %0A     * @param date%0A     * @return Manipulated date input%0A     */%0A    public Date parseNatty(String date) %7B%0A        %0A        // Initialises Natty parser%0A        Parser parser = new Parser();%0A        %0A        // Parses input String into a list of DateGroups%0A        List%3CDateGroup%3E dateGroupList = parser.parse(date);%0A        %0A        // Retrieves parsed date%0A        Date parsedDate = dateGroupList.get(0).getDates().get(0);%0A        %0A        return parsedDate;%0A    %7D%0A%0A    /**%0A     * Changes the initial date format of a string input for Natty.%0A     * %0A     * @param input%0A     * @return Formatted date in string format for Natty%0A     */%0A    public String changeToNattyDateFormat(String input) %7B%0A%0A        String output = %22%22;%0A%0A        try %7B%0A            SimpleDateFormat userDateFormat = new SimpleDateFormat(%22dd/MM/yyyy%22);%0A            Date userDateObject = userDateFormat.parse(input);%0A            SimpleDateFormat nattyDateFormat = new SimpleDateFormat(%22EEE MMM dd hh:mm:ss zzz yyyy%22);%0A            output = nattyDateFormat.format(userDateObject);%0A        %7D catch (ParseException pe) %7B%0A            System.out.println(%22User input date format to Natty date format: Parse Exception error!%22);%0A        %7D%0A%0A        return output;%0A    %7D%0A%0A    /**%0A     * Changes the final date format of a Date input for user.%0A     * %0A     * @param input%0A     * @return Formatted date in string format for user%0A     */%0A    public String changeToUserDateFormat(Date input) %7B%0A        SimpleDateFormat outputDateFormat = new SimpleDateFormat(%22dd/MM/YYYY%22);%0A        return outputDateFormat.format(input
 );%0A 

Modify TaskDate constructor to fit DD/MM/YYYY format