diff --git a/data/tasks.txt b/data/tasks.txt index 835f175774..c6b8f6b0cf 100644 --- a/data/tasks.txt +++ b/data/tasks.txt @@ -1,3 +1,3 @@ -T | 0 | test -T | 0 | 11 -T | 0 | 11 +T | 0 | CS2101 Reading +T | 0 | CS2103T IP finalize +D | 0 | CS2105 Assignment1 | 23:59 01/03/2020 diff --git a/src/main/java/hakunamatata/Parser.java b/src/main/java/hakunamatata/Parser.java index 400dfc8a8e..70e79cfbdd 100644 --- a/src/main/java/hakunamatata/Parser.java +++ b/src/main/java/hakunamatata/Parser.java @@ -282,8 +282,16 @@ public static boolean isInteger(String s) { * @return The date and time of the input LocalDateTime in String. */ public static String getDateTimeString(LocalDateTime dateTime) { - return dateTime.getHour() + ":" + dateTime.getMinute() - + " " + dateTime.getDayOfMonth() + "/" + dateTime.getMonthValue() + "/" + dateTime.getYear(); + String min = dateTime.getMinute() < 10 ? "0" + dateTime.getMinute() + : "" + dateTime.getMinute(); + String hour = dateTime.getHour() < 10 ? "0" + dateTime.getHour() + : "" + dateTime.getHour(); + String day = dateTime.getDayOfMonth() < 10 ? "0" + dateTime.getDayOfMonth() + : "" + dateTime.getDayOfMonth(); + String month = dateTime.getMonthValue() < 10 ? "0" + dateTime.getMonthValue() + : "" + dateTime.getMonthValue(); + return hour + ":" + min + + " " + day + "/" + month + "/" + dateTime.getYear(); } } diff --git a/src/main/java/hakunamatata/command/DeleteCommand.java b/src/main/java/hakunamatata/command/DeleteCommand.java index 5366e52f42..14476918af 100644 --- a/src/main/java/hakunamatata/command/DeleteCommand.java +++ b/src/main/java/hakunamatata/command/DeleteCommand.java @@ -38,7 +38,7 @@ public String execute(TaskList tasks, Ui ui, Storage storage) throws HakunaMatat if (originalListSize == 0) { throw new HakunaMatataException("emptyList"); } - if (this.index > originalListSize || index < 1) { + if (this.index > originalListSize || this.index < 1) { throw new HakunaMatataException("deleteWrongIndexRange"); } diff --git a/src/main/java/hakunamatata/task/Deadline.java b/src/main/java/hakunamatata/task/Deadline.java index 33941ea38f..684112007b 100644 --- a/src/main/java/hakunamatata/task/Deadline.java +++ b/src/main/java/hakunamatata/task/Deadline.java @@ -2,6 +2,8 @@ import java.time.LocalDateTime; +import hakunamatata.Parser; + /** * Represents a deadline task. * @@ -48,8 +50,8 @@ public LocalDateTime getBy() { */ @Override public String toString() { + return "[D]" + super.toString() - + " (by: " + by.getHour() + ":" + by.getMinute() - + " " + by.getDayOfMonth() + "/" + by.getMonthValue() + "/" + by.getYear() + ")"; + + " (by: " + Parser.getDateTimeString(this.by) + ")"; } }