-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.java
98 lines (79 loc) · 2.04 KB
/
Event.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class Event
{
private int ID;
private String title;
private String description;
private LocalDateTime dateTime;
public Event(int ID, String title, String description, LocalDateTime dateTime)
{
this.ID = ID;
this.title = title;
this.description = description;
this.dateTime = dateTime;
}
public Event(LocalDate date) //Title null (new Event)
{
dateTime = LocalDateTime.of(date, LocalTime.now());
}
public Event() {}
public int getID()
{
return ID;
}
public void setID(int ID)
{
this.ID = ID;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public LocalDateTime getDateTime()
{
return dateTime;
}
public String getDateTimeToString()
{
return dateTime.format(DateTimeFormatter.ofPattern("dd-MM-yyyy | HH:mm"));
}
public String getDateToString()
{
return dateTime.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
}
public String getTimeToString()
{
return dateTime.format(DateTimeFormatter.ofPattern("HH:mm"));
}
public void setDateTimeFromString(String dateTime)
{
this.dateTime = LocalDateTime.parse(dateTime, DateTimeFormatter.ofPattern("dd-MM-yyyy | HH:mm"));
}
public void setDateTime(LocalDateTime datetime)
{
this.dateTime = dateTime;
}
public void setTime(String time)
{
this.dateTime = LocalDateTime.of(dateTime.toLocalDate(), LocalTime.parse(time, DateTimeFormatter.ofPattern("HH:mm")));
}
public LocalDate getDate()
{
return dateTime.toLocalDate();
}
}