1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.class2.acal.dto; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.student.enrollment.class2.acal.util.CommonUtils; |
20 | |
|
21 | |
import java.text.DateFormat; |
22 | |
import java.text.SimpleDateFormat; |
23 | |
import java.util.Date; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class TimeSetWrapper { |
31 | |
private Date startDate; |
32 | |
private Date endDate; |
33 | |
private String startTime; |
34 | |
private String startTimeAmPm; |
35 | |
private String endTime; |
36 | |
private String endTimeAmPm; |
37 | |
private boolean allDay; |
38 | |
private boolean dateRange; |
39 | |
|
40 | |
|
41 | |
protected Date endDateUI; |
42 | |
|
43 | |
protected void buildDateAndTime(){ |
44 | |
|
45 | |
|
46 | 0 | endDateUI = getEndDate(); |
47 | |
|
48 | |
|
49 | 0 | if (!isAllDay()){ |
50 | |
|
51 | 0 | DateFormat dfm = new SimpleDateFormat("hh:mm"); |
52 | |
|
53 | 0 | if (getEndDate() != null){ |
54 | 0 | setStartTime(dfm.format(getStartDate())); |
55 | 0 | setEndTime(dfm.format(getEndDate())); |
56 | |
|
57 | 0 | dfm = new SimpleDateFormat("a"); |
58 | 0 | setStartTimeAmPm(dfm.format(getStartDate())); |
59 | 0 | setEndTimeAmPm(dfm.format(getEndDate())); |
60 | |
|
61 | 0 | String startDate = CommonUtils.formatDate(getStartDate()); |
62 | 0 | String endDate = CommonUtils.formatDate(getEndDate()); |
63 | |
|
64 | 0 | if (StringUtils.equals(startDate,endDate)){ |
65 | 0 | setDateRange(false); |
66 | 0 | setEndDate(null); |
67 | |
}else{ |
68 | 0 | setDateRange(true); |
69 | |
} |
70 | |
} |
71 | |
} |
72 | 0 | } |
73 | |
|
74 | |
public Date getStartDate() { |
75 | 0 | return startDate; |
76 | |
} |
77 | |
|
78 | |
public void setStartDate(Date startDate) { |
79 | 0 | this.startDate = startDate; |
80 | 0 | } |
81 | |
|
82 | |
public Date getEndDate() { |
83 | 0 | return endDate; |
84 | |
} |
85 | |
|
86 | |
public void setEndDate(Date endDate) { |
87 | 0 | this.endDate = endDate; |
88 | 0 | } |
89 | |
|
90 | |
public String getStartTime() { |
91 | 0 | return startTime; |
92 | |
} |
93 | |
|
94 | |
public void setStartTime(String startTime) { |
95 | 0 | this.startTime = startTime; |
96 | 0 | } |
97 | |
|
98 | |
public String getStartTimeAmPm() { |
99 | 0 | return startTimeAmPm; |
100 | |
} |
101 | |
|
102 | |
public void setStartTimeAmPm(String startTimeAmPm) { |
103 | 0 | this.startTimeAmPm = startTimeAmPm; |
104 | 0 | } |
105 | |
|
106 | |
public String getEndTime() { |
107 | 0 | return endTime; |
108 | |
} |
109 | |
|
110 | |
public void setEndTime(String endTime) { |
111 | 0 | this.endTime = endTime; |
112 | 0 | } |
113 | |
|
114 | |
public String getEndTimeAmPm() { |
115 | 0 | return endTimeAmPm; |
116 | |
} |
117 | |
|
118 | |
public void setEndTimeAmPm(String endTimeAmPm) { |
119 | 0 | this.endTimeAmPm = endTimeAmPm; |
120 | 0 | } |
121 | |
|
122 | |
public boolean isAllDay() { |
123 | 0 | return allDay; |
124 | |
} |
125 | |
|
126 | |
public void setAllDay(boolean allDay) { |
127 | 0 | this.allDay = allDay; |
128 | 0 | } |
129 | |
|
130 | |
public boolean isDateRange() { |
131 | 0 | return dateRange; |
132 | |
} |
133 | |
|
134 | |
public void setDateRange(boolean dateRange) { |
135 | 0 | this.dateRange = dateRange; |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
protected String formatStartDateUI(Date startDate){ |
140 | 0 | if (startDate != null) { |
141 | 0 | if (!isAllDay()){ |
142 | 0 | SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm aa"); |
143 | 0 | String formattedDate = formatter.format(startDate); |
144 | 0 | if (StringUtils.endsWithIgnoreCase(formattedDate,"12:00 am")){ |
145 | 0 | return StringUtils.removeEndIgnoreCase(formattedDate,"12:00 am"); |
146 | |
}else { |
147 | 0 | return formattedDate; |
148 | |
} |
149 | |
}else{ |
150 | 0 | SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); |
151 | 0 | return formatter.format(startDate); |
152 | |
} |
153 | |
}else{ |
154 | 0 | return StringUtils.EMPTY; |
155 | |
} |
156 | |
|
157 | |
} |
158 | |
|
159 | |
|
160 | |
protected String formatEndDateUI(Date endDate){ |
161 | 0 | if (endDate != null) { |
162 | 0 | if (!isAllDay()){ |
163 | 0 | SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm aa"); |
164 | 0 | String formattedDate = formatter.format(endDate); |
165 | 0 | if (StringUtils.endsWithIgnoreCase(formattedDate,"11:59 pm")){ |
166 | 0 | return StringUtils.removeEndIgnoreCase(formattedDate,"11:59 pm"); |
167 | |
}else { |
168 | 0 | return formattedDate; |
169 | |
} |
170 | |
}else{ |
171 | 0 | SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); |
172 | 0 | return formatter.format(endDate); |
173 | |
} |
174 | |
}else{ |
175 | 0 | return StringUtils.EMPTY; |
176 | |
} |
177 | |
|
178 | |
} |
179 | |
|
180 | |
} |