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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
package net.cbaines.suca;
import java.security.InvalidParameterException;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* All info from here
* https://www.soton.ac.uk/studentadmin/academic_year/index.html
*
* @author Christopher Baines <cbaines8@gmail.com>
*
*/
public final class UniTermDates {
/**
* Periods
*/
public static final int AUTUMN_TERM = 0;
public static final int SPRING_TERM = 1;
public static final int SUMMER_TERM = 2;
public static final int SEMESTER_1 = 3;
public static final int SEMESTER_2 = 4;
public static final int YEAR_BEGINING_2011 = 2011;
public static final int YEAR_BEGINING_2012 = 2012;
public static final int YEAR_BEGINING_2013 = 2013;
public static final int YEAR_BEGINING_2014 = 2014;
public static final int YEAR_BEGINING_2015 = 2015;
public static final int YEAR_BEGINING_2016 = 2016;
public static final int YEAR_BEGINING_2017 = 2017;
public static final int YEAR_BEGINING_2018 = 2018;
public static final int YEAR_BEGINING_2019 = 2019;
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] startOfAutumnTermAndSemester1 = {
new GregorianCalendar(2011, Calendar.SEPTEMBER, 29),
new GregorianCalendar(2012, Calendar.SEPTEMBER, 27),
new GregorianCalendar(2013, Calendar.SEPTEMBER, 26),
new GregorianCalendar(2014, Calendar.SEPTEMBER, 25),
new GregorianCalendar(2015, Calendar.SEPTEMBER, 24),
new GregorianCalendar(2016, Calendar.SEPTEMBER, 29),
new GregorianCalendar(2017, Calendar.SEPTEMBER, 28),
new GregorianCalendar(2018, Calendar.SEPTEMBER, 27),
new GregorianCalendar(2019, Calendar.SEPTEMBER, 26) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] endOfAutumnTerm = {
new GregorianCalendar(2011, Calendar.DECEMBER, 17),
new GregorianCalendar(2012, Calendar.DECEMBER, 15),
new GregorianCalendar(2013, Calendar.DECEMBER, 14),
new GregorianCalendar(2014, Calendar.DECEMBER, 13),
new GregorianCalendar(2015, Calendar.DECEMBER, 12),
new GregorianCalendar(2016, Calendar.DECEMBER, 17),
new GregorianCalendar(2017, Calendar.DECEMBER, 16),
new GregorianCalendar(2018, Calendar.DECEMBER, 15),
new GregorianCalendar(2019, Calendar.DECEMBER, 14) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] startOfSpringTerm = {
new GregorianCalendar(2012, Calendar.JANUARY, 9),
new GregorianCalendar(2013, Calendar.JANUARY, 7),
new GregorianCalendar(2014, Calendar.JANUARY, 6),
new GregorianCalendar(2015, Calendar.JANUARY, 5),
new GregorianCalendar(2016, Calendar.JANUARY, 4),
new GregorianCalendar(2017, Calendar.JANUARY, 9),
new GregorianCalendar(2018, Calendar.JANUARY, 8),
new GregorianCalendar(2019, Calendar.JANUARY, 7),
new GregorianCalendar(2020, Calendar.JANUARY, 6) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] endOfSemester1 = {
new GregorianCalendar(2012, Calendar.JANUARY, 28),
new GregorianCalendar(2013, Calendar.JANUARY, 26),
new GregorianCalendar(2014, Calendar.JANUARY, 25),
new GregorianCalendar(2015, Calendar.JANUARY, 24),
new GregorianCalendar(2016, Calendar.JANUARY, 23),
new GregorianCalendar(2017, Calendar.JANUARY, 28),
new GregorianCalendar(2018, Calendar.JANUARY, 27),
new GregorianCalendar(2019, Calendar.JANUARY, 26),
new GregorianCalendar(2020, Calendar.JANUARY, 25) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] startOfSemester2 = {
new GregorianCalendar(2012, Calendar.JANUARY, 30),
new GregorianCalendar(2013, Calendar.JANUARY, 28),
new GregorianCalendar(2014, Calendar.JANUARY, 27),
new GregorianCalendar(2015, Calendar.JANUARY, 26),
new GregorianCalendar(2016, Calendar.JANUARY, 25),
new GregorianCalendar(2017, Calendar.JANUARY, 30),
new GregorianCalendar(2018, Calendar.JANUARY, 29),
new GregorianCalendar(2019, Calendar.JANUARY, 28),
new GregorianCalendar(2020, Calendar.JANUARY, 27) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] endOfSpringTerm = {
new GregorianCalendar(2012, Calendar.MARCH, 17),
new GregorianCalendar(2013, Calendar.MARCH, 16),
new GregorianCalendar(2014, Calendar.MARCH, 29),
new GregorianCalendar(2015, Calendar.MARCH, 21),
new GregorianCalendar(2016, Calendar.MARCH, 19),
new GregorianCalendar(2017, Calendar.MARCH, 25),
new GregorianCalendar(2018, Calendar.MARCH, 17),
new GregorianCalendar(2019, Calendar.MARCH, 30),
new GregorianCalendar(2020, Calendar.MARCH, 21) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] startOfSummerTerm = {
new GregorianCalendar(2012, Calendar.APRIL, 16),
new GregorianCalendar(2013, Calendar.APRIL, 15),
new GregorianCalendar(2014, Calendar.APRIL, 28),
new GregorianCalendar(2015, Calendar.APRIL, 20),
new GregorianCalendar(2016, Calendar.APRIL, 18),
new GregorianCalendar(2017, Calendar.APRIL, 24),
new GregorianCalendar(2018, Calendar.APRIL, 16),
new GregorianCalendar(2019, Calendar.APRIL, 29),
new GregorianCalendar(2020, Calendar.APRIL, 20) };
/**
* Start dates for the Autumn term's for each Academic Year starting from
* 2011 to 2019.
*/
private static final GregorianCalendar[] endOfSummerTermAndSemester2 = {
new GregorianCalendar(2012, Calendar.JUNE, 16),
new GregorianCalendar(2013, Calendar.JUNE, 15),
new GregorianCalendar(2014, Calendar.JUNE, 14),
new GregorianCalendar(2015, Calendar.JUNE, 13),
new GregorianCalendar(2016, Calendar.JUNE, 11),
new GregorianCalendar(2017, Calendar.JUNE, 17),
new GregorianCalendar(2018, Calendar.JUNE, 16),
new GregorianCalendar(2019, Calendar.JUNE, 15),
new GregorianCalendar(2020, Calendar.JUNE, 13) };
public static GregorianCalendar getStartOf(int period, int academicYear) {
if (academicYear < YEAR_BEGINING_2011
|| academicYear > YEAR_BEGINING_2019) {
throw new InvalidParameterException();
}
if (period == AUTUMN_TERM) {
return (GregorianCalendar) startOfAutumnTermAndSemester1[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SPRING_TERM) {
return (GregorianCalendar) startOfSpringTerm[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SUMMER_TERM) {
return (GregorianCalendar) startOfSummerTerm[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SEMESTER_1) {
return (GregorianCalendar) startOfAutumnTermAndSemester1[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SEMESTER_2) {
return (GregorianCalendar) startOfSemester2[academicYear
- YEAR_BEGINING_2011].clone();
} else {
throw new InvalidParameterException();
}
}
public static GregorianCalendar getEndOf(int period, int academicYear) {
if (academicYear < YEAR_BEGINING_2011
|| academicYear > YEAR_BEGINING_2019) {
throw new InvalidParameterException();
}
if (period == AUTUMN_TERM) {
return (GregorianCalendar) endOfAutumnTerm[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SPRING_TERM) {
return (GregorianCalendar) endOfSpringTerm[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SUMMER_TERM) {
return (GregorianCalendar) endOfSummerTermAndSemester2[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SEMESTER_1) {
return (GregorianCalendar) endOfSemester1[academicYear
- YEAR_BEGINING_2011].clone();
} else if (period == SEMESTER_2) {
return (GregorianCalendar) endOfSummerTermAndSemester2[academicYear
- YEAR_BEGINING_2011].clone();
} else {
throw new InvalidParameterException();
}
}
}
|