Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java @ 784:7b81d563c8c0
Improved date input validation. A given date needs to be in a specific range (issue212).
gnv-artifacts/trunk@866 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 30 Mar 2010 09:17:53 +0000 |
parents | c4156275c1e1 |
children | e764cab8c885 |
comparison
equal
deleted
inserted
replaced
783:3509735619e7 | 784:7b81d563c8c0 |
---|---|
161 } | 161 } |
162 return new GeometryFactory().createPoint(new Coordinate(x,y)); | 162 return new GeometryFactory().createPoint(new Coordinate(x,y)); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 | |
167 public boolean isDateValid(Date tmp, Date lo, Date up) { | |
168 // we need to transform the given dates into seconds, because | |
169 // they differ in milliseconds -> that's why we cannot use the | |
170 // Date.compareTo(Date) method. | |
171 long tmpTime = tmp.getTime() / 1000; | |
172 long tmpLow = lo.getTime() / 1000; | |
173 long tmpUp = up.getTime() / 1000; | |
174 | |
175 if (tmpTime < tmpLow || tmpTime > tmpUp) { | |
176 log.warn( | |
177 "Date [" + tmp.toString() + "] is out of range [" | |
178 + lo.toString() + " to "+ up.toString() + "]."); | |
179 return false; | |
180 } | |
181 | |
182 return true; | |
183 } | |
166 } | 184 } |