package seedu.jobs.model.task;

import java.util.Optional;

import seedu.jobs.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's time signature in JOBS. Guarantees: immutable; is valid
 * as declared in {@link #isValidTime(String)}
 */

public class Time {

    public static final String MESSAGE_TIME_CONSTRAINT = "Time should always follow the dd/mm/yy hh:mm format";
    public static final String TIME_VALIDATION_REGEX = "^[0-3]*[0-9]/[0-3]*[0-9]/(?:[0-9][0-9])?[0-9][0-9]\\s+(0*[1-9]|1[0-9]|2[0-3]):(0[0-9]|[1-5][0-9])";

    public static final String DEFAULT_TIME = "";
    public String value;

    /**
     * Validates given time-values input.
     *
     * @throws IllegalValueException
     *             if the input is invalid
     */
    public Time(Optional<String> startTime) throws IllegalValueException {
        if (!startTime.isPresent()) {
            this.value = DEFAULT_TIME;
        } 
        else {
        	if(startTime.get().equals("")){
        		this.value = DEFAULT_TIME;
        	}
        	else if (!isValidTime(startTime.get())) {
                throw new IllegalValueException(MESSAGE_TIME_CONSTRAINT);
            }
        	else{
                this.value = startTime.get();
        	}
        }
    }

    /**
     * Returns true if a given string is in valid time format
     */
    public static boolean isValidTime(String test) {
        return test.matches(TIME_VALIDATION_REGEX);
    }

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

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

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

}

@@ -41,21 +41,243 @@
 ava.
-util.Optional
+time.LocalDate;%0Aimport java.time.format.DateTimeFormatter;%0Aimport java.time.format.DateTimeParseException;%0Aimport java.time.format.ResolverStyle;%0Aimport java.util.Optional;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern
 ;%0A%0Ai
@@ -635,19 +635,19 @@
  String 
-TIM
+DAT
 E_VALIDA
@@ -665,35 +665,42 @@
 = %22%5E
+(
 %5B0-
-3%5D*
+2%5D
 %5B0-9%5D
-/
+%7C3%5B0-1%5D)/(
 %5B0-3%5D
-*
 %5B0-9%5D
+)
 /(
-?:
 %5B0-9
@@ -709,10 +709,8 @@
 0-9%5D
-)?
 %5B0-9
@@ -719,15 +719,70 @@
 0-9%5D
-%5C%5Cs+
+)%22;%0A    public static final String TIME_VALIDATION_REGEX = %22
 (0
-*
 %5B1-9
@@ -820,17 +820,16 @@
 0-9%5D)%22;%0A
-%0A
     publ
@@ -1675,62 +1675,1031 @@
     
-    return test.matches(TIME_VALIDATION_REGEX)
+%09String time = extractTime(test);%0A    %09String date = extractDate(test);%0A        try%7B%0A        %09LocalDate.parse(date,DateTimeFormatter.ofPattern(%22dd/MM/uuuu%22).withResolverStyle(ResolverStyle.STRICT));%0A        %7D%0A        catch(DateTimeParseException e)%7B%0A        %09return false;%0A        %7D%0A        return time.length()%3E0;%0A    %7D%09%0A    %0A    /**%0A     * Extract date (dd/mm/yyyy) from an input string%0A     */%0A    private static String extractDate(String date)%7B%0A%09%09Pattern datePattern = Pattern.compile(DATE_VALIDATION_REGEX);%0A%09%09Matcher dateMatcher = datePattern.matcher(date);%0A%09%09String value = %22%22;%0A%09%09while (dateMatcher.find()) %7B%0A%09%09%09value+=(dateMatcher.group());%0A%09%09%7D%0A%09%09return value;%0A    %7D%0A    %0A    /**%0A     * extract time (HH:mm) from an input string%0A     */%0A    private static String extractTime(String time)%7B%0A%09%09Pattern timePattern = Pattern.compile(TIME_VALIDATION_REGEX);%0A%09%09Matcher timeMatcher = timePattern.matcher(time);%0A%09%09String value = %22%22;%0A%09%09while (timeMatcher.find()) %7B%0A%09%09%09value+=(timeMatcher.group());%0A%09%09%7D%0A%09%09return value
 ;%0A    %7D%0A
 %0A   
@@ -2686,32 +2686,36 @@
 rn value;%0A    %7D%0A
+    
 %0A    @Override%0A 

Fix time format