changeset 9413:b534a4f4e4f6

micro review
author gernotbelger
date Thu, 16 Aug 2018 12:04:46 +0200
parents 0fb76f2d4e5b
children 096f151a0a9f
files artifacts/src/main/java/org/dive4elements/river/artifacts/services/DynamicMainValuesTimeRangeDeterminationService.java
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DynamicMainValuesTimeRangeDeterminationService.java	Thu Aug 16 11:40:28 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DynamicMainValuesTimeRangeDeterminationService.java	Thu Aug 16 12:04:46 2018 +0200
@@ -38,8 +38,6 @@
 
     private static final String ROOT_NODE = "dynamic-mainvalues-input";
 
-    private static final Long DATE_DELTA_ERROR_MSG = (long) (60 * 60 * 24 * 1000);
-
     public static final class ServiceException extends Exception {
 
         private static final long serialVersionUID = 1L;
@@ -115,8 +113,8 @@
         // common Range and correct errorMsg
         final List<GaugeInfoResult.GaugeInfo> gaugeResultsSecondTurn = new ArrayList<>();
         for (final GaugeInfoResult.GaugeInfo gi : gaugeResults) {
-            gaugeResultsSecondTurn.add(new GaugeInfoResult.GaugeInfo(gi.errorMsg, gi.gauge, gi.startdate != null ? min : null,
-                    gi.enddate != null ? max : null));
+            gaugeResultsSecondTurn
+                    .add(new GaugeInfoResult.GaugeInfo(gi.errorMsg, gi.gauge, gi.startdate != null ? min : null, gi.enddate != null ? max : null));
         }
         if (globalErrorMsg.isEmpty() && (min.getTime() > max.getTime()))
             globalErrorMsg = getMsg(meta, "bundu.wst.gauge_timeranges_disjoint");
@@ -127,11 +125,11 @@
 
     private String makeDoesNotCoverErrorMsg(final Date start, final Date end, final CallMeta meta) {
         final Calendar cal = Calendar.getInstance();
-        cal.setTime(start);
-        final String startyear = String.valueOf(cal.get(Calendar.YEAR));
-        cal.setTime(end);
-        final String endyear = String.valueOf(cal.get(Calendar.YEAR));
-        return Resources.getMsg(meta, "bundu.wst.range_does_not_cover", new Object[] { startyear, endyear });
+        return Resources.getMsg(meta, "bundu.wst.range_does_not_cover", new Object[] { getYear(start, cal), getYear(end, cal) });
+    }
+
+    private String getYear(final Date d, final Calendar cal) {
+        return String.valueOf(cal.get(Calendar.YEAR));
     }
 
     @Override

http://dive4elements.wald.intevation.org