File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ public class ErrorHandler {
3434 /** Error message for invalid direction format */
3535 public static final String ERROR_DIRECTION_FORMAT =
3636 "Please enter ascending or descending for the sorted order (×͡×)" ;
37+ /** Error message for invalid start date after end date */
38+ public static final String ERROR_DAY_FORMAT =
39+ "Oh no! The start date cannot be after the end date. "
40+ + "Please make sure your event starts before it ends :)" ;
41+ /** Error message for invalid start date equal end date */
42+ public static final String ERROR_DAY_FORMAT_EQUALS =
43+ "Oh no! The start date and end date cannot be the same. :(" ;
3744
3845 /**
3946 * Handles the cases where the direction is not in the right format.
@@ -126,6 +133,14 @@ public static String[] validateEventFormat(String eventInStringForm) throws Phuc
126133 throw new PhucException (ERROR_EVENT_FORMAT );
127134 }
128135
136+ if (validateAndParseDateTime (startDate ).isAfter (validateAndParseDateTime (endDate ))) {
137+ throw new PhucException (ERROR_DAY_FORMAT );
138+ }
139+
140+ if (validateAndParseDateTime (startDate ).isEqual (validateAndParseDateTime (endDate ))) {
141+ throw new PhucException (ERROR_DAY_FORMAT_EQUALS );
142+ }
143+
129144 String [] eventParts = new String [3 ];
130145 eventParts [0 ] = description ;
131146 eventParts [1 ] = startDate ;
You can’t perform that action at this time.
0 commit comments