changeset 8180:00066d3add94

The existing implementation respects the fact that months are 0-based.
author Tom Gottfried <tom@intevation.de>
date Wed, 03 Sep 2014 18:21:35 +0200
parents 705f8b92fd66
children baa7df019df3
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java
diffstat 1 files changed, 4 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java	Wed Sep 03 16:46:09 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java	Wed Sep 03 18:21:35 2014 +0200
@@ -12,6 +12,8 @@
 import java.util.Date;
 import java.util.List;
 
+import org.dive4elements.river.utils.DateUtil;
+
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value.Filter;
 
@@ -131,20 +133,8 @@
         }
 
         public TimeRangeIntersects(int startYear, int endYear) {
-            this(firstJan(Math.min(startYear, endYear)),
-                lastDec(Math.max(startYear, endYear)));
-        }
-
-        private static Date firstJan(int year) {
-            Calendar cal = Calendar.getInstance();
-            cal.set(year, 1, 1, 0, 0, 0);
-            return cal.getTime();
-        }
-
-        private static Date lastDec(int year) {
-            Calendar cal = Calendar.getInstance();
-            cal.set(year, 12, 31, 23, 59, 59);
-            return cal.getTime();
+            this(DateUtil.getStartDateFromYear(Math.min(startYear, endYear)),
+                 DateUtil.getEndDateFromYear(Math.max(startYear, endYear)));
         }
 
         public TimeRangeIntersects(Date a, Date b) {

http://dive4elements.wald.intevation.org