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.r2.common.util.date.DateFormatters;
20
21 import java.util.Date;
22
23
24
25
26
27
28 public class TimeSetWrapper {
29 private Date startDate;
30 private Date endDate;
31 private String startTime;
32 private String startTimeAmPm;
33 private String endTime;
34 private String endTimeAmPm;
35 private boolean allDay;
36 private boolean dateRange;
37
38
39 protected Date endDateUI;
40
41 protected void buildDateAndTime(){
42
43
44 endDateUI = getEndDate();
45
46
47 setStartTimeAmPm("AM");
48 setEndTimeAmPm("AM");
49
50
51 if (!isAllDay()){
52 if (getStartDate() != null){
53 setStartTime(DateFormatters.HOUR_MINUTE_TIME_FORMATTER.format(getStartDate()));
54 setStartTimeAmPm(DateFormatters.AM_PM_TIME_FORMATTER.format(getStartDate()));
55 }
56 if (getEndDate() != null){
57 setEndTime(DateFormatters.HOUR_MINUTE_TIME_FORMATTER.format(getEndDate()));
58 setEndTimeAmPm(DateFormatters.AM_PM_TIME_FORMATTER.format(getEndDate()));
59 }
60 } else if (!isDateRange()){
61 setEndDate(null);
62 setEndTime(null);
63 }
64 }
65
66 public Date getStartDate() {
67 return startDate;
68 }
69
70 public void setStartDate(Date startDate) {
71 this.startDate = startDate;
72 }
73
74 public Date getEndDate() {
75 return endDate;
76 }
77
78 public void setEndDate(Date endDate) {
79 this.endDate = endDate;
80 }
81
82 public String getStartTime() {
83 return startTime;
84 }
85
86 public void setStartTime(String startTime) {
87 this.startTime = startTime;
88 }
89
90 public String getStartTimeAmPm() {
91 return startTimeAmPm;
92 }
93
94 public void setStartTimeAmPm(String startTimeAmPm) {
95 this.startTimeAmPm = startTimeAmPm;
96 }
97
98 public String getEndTime() {
99 return endTime;
100 }
101
102 public void setEndTime(String endTime) {
103 this.endTime = endTime;
104 }
105
106 public String getEndTimeAmPm() {
107 return endTimeAmPm;
108 }
109
110 public void setEndTimeAmPm(String endTimeAmPm) {
111 this.endTimeAmPm = endTimeAmPm;
112 }
113
114 public boolean isAllDay() {
115 return allDay;
116 }
117
118 public void setAllDay(boolean allDay) {
119 this.allDay = allDay;
120 }
121
122 public boolean isDateRange() {
123 return dateRange;
124 }
125
126 public void setDateRange(boolean dateRange) {
127 this.dateRange = dateRange;
128 }
129
130
131 protected String formatStartDateUI(Date startDate){
132 if (startDate != null) {
133 if (!isAllDay()){
134 String formattedDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(startDate);
135 return StringUtils.removeEndIgnoreCase(formattedDate,"12:00 am");
136 }else{
137 return DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(startDate);
138 }
139 }else{
140 return StringUtils.EMPTY;
141 }
142
143 }
144
145
146 protected String formatEndDateUI(Date endDate){
147 if (endDate != null) {
148 if (!isAllDay()){
149 String formattedEndDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(endDate);
150 String formattedStartDate = DateFormatters.MONTH_DAY_YEAR_TIME_DATE_FORMATTER.format(startDate);
151 String strippedDate = StringUtils.removeStart(formattedEndDate,StringUtils.substringBefore(formattedStartDate," "));
152 return StringUtils.removeEndIgnoreCase(strippedDate,"11:59 pm");
153 }else{
154 if (isDateRange()){
155 return DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(endDate);
156 }else{
157 return StringUtils.EMPTY;
158 }
159 }
160 }else{
161 return StringUtils.EMPTY;
162 }
163
164 }
165
166 }