comparison backend/src/main/java/org/dive4elements/river/utils/DateGuesser.java @ 5882:7100059790df

DateGuesser: set times exactly (without parts of import time)
author Tom Gottfried <tom.gottfried@intevation.de>
date Tue, 30 Apr 2013 11:14:58 +0200
parents 4dd33b86dc61
children 4110565baff8
comparison
equal deleted inserted replaced
5881:1afeb674381d 5882:7100059790df
85 if (m.matches()) { 85 if (m.matches()) {
86 Calendar cal = Calendar.getInstance(); 86 Calendar cal = Calendar.getInstance();
87 String year = m.group(1); 87 String year = m.group(1);
88 String month = m.group(2); 88 String month = m.group(2);
89 String day = m.group(3); 89 String day = m.group(3);
90 cal.clear();
90 cal.set( 91 cal.set(
91 Integer.parseInt(year), 92 Integer.parseInt(year),
92 calendarMonth(month), 93 calendarMonth(month),
93 Integer.parseInt(day), 94 Integer.parseInt(day),
94 12, 0, 0); 95 12, 0, 0);
100 if (m.matches()) { 101 if (m.matches()) {
101 Calendar cal = Calendar.getInstance(); 102 Calendar cal = Calendar.getInstance();
102 String year = m.group(3); 103 String year = m.group(3);
103 String month = m.group(2); 104 String month = m.group(2);
104 String day = m.group(1); 105 String day = m.group(1);
106 cal.clear();
105 cal.set( 107 cal.set(
106 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), 108 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0),
107 calendarMonth(month), 109 calendarMonth(month),
108 Integer.parseInt(m.group(1)), 110 Integer.parseInt(m.group(1)),
109 12, 0, 0); 111 12, 0, 0);
116 int month = guessMonth(m.group(2)); 118 int month = guessMonth(m.group(2));
117 if (month >= 0) { 119 if (month >= 0) {
118 Calendar cal = Calendar.getInstance(); 120 Calendar cal = Calendar.getInstance();
119 String year = m.group(3); 121 String year = m.group(3);
120 String day = m.group(1); 122 String day = m.group(1);
123 cal.clear();
121 cal.set( 124 cal.set(
122 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), 125 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0),
123 month, 126 month,
124 day.length() == 0 ? 15 : Integer.parseInt(day), 127 day.length() == 0 ? 15 : Integer.parseInt(day),
125 12, 0, 0); 128 12, 0, 0);
134 String year = m.group(1); 137 String year = m.group(1);
135 String month = m.group(2); 138 String month = m.group(2);
136 String day = m.group(3); 139 String day = m.group(3);
137 String hour = m.group(4); 140 String hour = m.group(4);
138 String minute = m.group(5); 141 String minute = m.group(5);
142 cal.clear();
139 cal.set( 143 cal.set(
140 Integer.parseInt(year), 144 Integer.parseInt(year),
141 calendarMonth(month), 145 calendarMonth(month),
142 Integer.parseInt(day), 146 Integer.parseInt(day),
143 Integer.parseInt(hour), 147 Integer.parseInt(hour),
155 String month = m.group(2); 159 String month = m.group(2);
156 String day = m.group(3); 160 String day = m.group(3);
157 String hour = m.group(4); 161 String hour = m.group(4);
158 String minute = m.group(5); 162 String minute = m.group(5);
159 String second = m.group(6); 163 String second = m.group(6);
164 cal.clear();
160 cal.set( 165 cal.set(
161 Integer.parseInt(year), 166 Integer.parseInt(year),
162 calendarMonth(month), 167 calendarMonth(month),
163 Integer.parseInt(day), 168 Integer.parseInt(day),
164 Integer.parseInt(hour), 169 Integer.parseInt(hour),
175 String year = m.group(3); 180 String year = m.group(3);
176 String month = m.group(2); 181 String month = m.group(2);
177 String day = m.group(1); 182 String day = m.group(1);
178 String hour = m.group(4); 183 String hour = m.group(4);
179 String minute = m.group(5); 184 String minute = m.group(5);
185 cal.clear();
180 cal.set( 186 cal.set(
181 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), 187 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0),
182 calendarMonth(month), 188 calendarMonth(month),
183 Integer.parseInt(day), 189 Integer.parseInt(day),
184 Integer.parseInt(hour), 190 Integer.parseInt(hour),
196 String month = m.group(2); 202 String month = m.group(2);
197 String day = m.group(1); 203 String day = m.group(1);
198 String hour = m.group(4); 204 String hour = m.group(4);
199 String minute = m.group(5); 205 String minute = m.group(5);
200 String second = m.group(6); 206 String second = m.group(6);
207 cal.clear();
201 cal.set( 208 cal.set(
202 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), 209 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0),
203 calendarMonth(month), 210 calendarMonth(month),
204 Integer.parseInt(day), 211 Integer.parseInt(day),
205 Integer.parseInt(hour), 212 Integer.parseInt(hour),
222 year += 2000; 229 year += 2000;
223 } 230 }
224 else { 231 else {
225 year += 1900; 232 year += 1900;
226 } 233 }
234 cal.clear();
227 cal.set( 235 cal.set(
228 year, 236 year,
229 Integer.parseInt(month), // month 237 Integer.parseInt(month), // month
230 Integer.parseInt(day), // day 238 Integer.parseInt(day), // day
231 12, 0, 0); 239 12, 0, 0);
235 m = GARBAGE_YYYY.matcher(s); 243 m = GARBAGE_YYYY.matcher(s);
236 244
237 if (m.matches()) { 245 if (m.matches()) {
238 Calendar cal = Calendar.getInstance(); 246 Calendar cal = Calendar.getInstance();
239 String year = m.group(1); 247 String year = m.group(1);
248 cal.clear();
240 cal.set( 249 cal.set(
241 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0), 250 Integer.parseInt(year) + (year.length() == 2 ? 1900 : 0),
242 5, // month 251 5, // month
243 15, // day 252 15, // day
244 12, 0, 0); 253 12, 0, 0);

http://dive4elements.wald.intevation.org