Skip to content

Commit

Permalink
Merge branch 'branch-Level-8'
Browse files Browse the repository at this point in the history
  • Loading branch information
gachia committed Aug 27, 2019
2 parents 388dd77 + 9b90d64 commit f3253ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.io.File;
import java.io.FileWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Duke {

Expand Down Expand Up @@ -65,6 +67,9 @@ public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String taskName;
Task task;
//Time
final String timePattern = "d MMMM yyyy, h:mma";
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern(timePattern);
while (sc.hasNext()) {
try {
String userCmd = sc.next();
Expand Down Expand Up @@ -101,7 +106,9 @@ public static void main(String[] args) {
if (userWords.length == 1) {
throw new DukeException("☹ OOPS!!! The date/time of a deadline cannot be empty or is wrongly typed.");
}
task = new Deadline(userWords[0].trim(), userWords[1].trim());
LocalDateTime dateObj = LocalDateTime.parse(userWords[1].trim(), DateTimeFormatter.ofPattern("d/MM/yyyy Hmm"));
String date = dateObj.format(dateTimeFormat);
task = new Deadline(userWords[0].trim(), date);
list.add(task);
System.out.println(lineSpace + "Got it. I've added this task:\n" + task
+ "\nNow you have " + list.size() + " tasks in the list.\n" + lineSpace);
Expand Down

0 comments on commit f3253ba

Please sign in to comment.