-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ticket.java
35 lines (29 loc) · 965 Bytes
/
Ticket.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
import java.util.Calendar;
import java.util.Date;
import java.io.Serializable;
public class Ticket implements Comparable<Ticket>, Serializable {
Date datetime;
HourType hourType;
TicketType ticketType;
String employeeId;
public Ticket(Date datetime, HourType hourType, TicketType ticketType, String employeeId) {
this.datetime = datetime;
this.hourType = hourType;
this.ticketType = ticketType;
this.employeeId = employeeId;
}
public Ticket(HourType hourType, TicketType ticketType, String employeeId) {
this(new Date(), hourType, ticketType, employeeId);
}
public static String keyFromDate(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return "" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DAY_OF_WEEK) + "-" + cal.get(Calendar.YEAR);
}
public int compareTo(Ticket ticket) {
return this.datetime.compareTo(ticket.datetime);
}
public String dateKey() {
return Ticket.keyFromDate(datetime);
}
}