-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathEvent.java
More file actions
28 lines (24 loc) · 851 Bytes
/
Event.java
File metadata and controls
28 lines (24 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.LocalTime;
public class Event extends Task {
protected String dateTime;
protected String date;
protected String time;
protected LocalDate date1;
protected LocalTime time1;
public Event(String description, String dateTime) {
super(description);
this.dateTime = dateTime;
String[] splits = dateTime.split("\\s+");
this.date = splits[0];
this.time = splits[1];
this.date1 = LocalDate.parse(date);
this.time1 = LocalTime.parse(time);
}
@Override
public String toString() {
return "[E]" + super.toString() + " (at: " + date1.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + " " +
time1.format(DateTimeFormatter.ofPattern("HH:mm")) + ")";
}
}