[Schmitzm-commits] r2139 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sun Nov 11 20:51:44 CET 2012


Author: alfonx
Date: 2012-11-11 20:51:44 +0100 (Sun, 11 Nov 2012)
New Revision: 2139

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
Log:


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-11-11 19:42:30 UTC (rev 2138)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-11-11 19:51:44 UTC (rev 2139)
@@ -476,6 +476,32 @@
 	}
 
 	/**
+	 * Increases a date by hours.
+	 * 
+	 * @param date
+	 *            date to increase
+	 * @param hours
+	 *            days to increase the date with
+	 * @return a new {@link Date} instance
+	 */
+	public static Date incHours(Date date, double days) {
+		return incDate(date, (long) (days * HOUR_MILLIS));
+	}
+
+	/**
+	 * Decreses a date by hours.
+	 * 
+	 * @param date
+	 *            date to decrease
+	 * @param hours
+	 *            hours to decrease the date with
+	 * @return a new {@link Date} instance
+	 */
+	public static Date decHours(Date date, double hours) {
+		return incHours(date, -hours);
+	}
+
+	/**
 	 * Tries several date formats to parse a date string.
 	 * 
 	 * @param dateStr
@@ -2593,28 +2619,28 @@
 		int gBytes = (int) Math.round(bytes * 1.0 / LangUtil.GB_BYTES);
 		return kBytes + " GB";
 	}
-    
-    
-    /**
-     * Replaces all {@code ${0}}, {@code ${1}}, ... occurencies (wildcards)
-     * in a string with the given parameters.
-     * @param string
-     *            String which contains the wildcards 
-     * @param replParams
-     *            Strings/Numbers, which are used as replacements for the
-     *            wildcards <code>${0}</code>, <code>${1}</code>, <code>${2}</code>, etc.
-     */
-    public static String replaceParameters(String string, Object... replParams) {
-      String replString = null;
-      for (int i = 0; i < replParams.length; i++) {
-        replString = replParams[i] != null ? replParams[i].toString() : "null";
-        // Problem with replacement of '$' sign in
-        // replace string, so first quote these characters
-        // in the replacement
-        replString = Matcher.quoteReplacement(replString);
-        // Perform the "real" replacement for the ${..}
-        string = string.replaceAll("\\$\\{" + i + "\\}", replString);
-      }
-      return string;
-    }
+
+	/**
+	 * Replaces all {@code $ 0} , {@code $ 1} , ... occurencies (wildcards) in a string with the given parameters.
+	 * 
+	 * @param string
+	 *            String which contains the wildcards
+	 * @param replParams
+	 *            Strings/Numbers, which are used as replacements for the wildcards <code>${0}</code>, <code>${1}</code>
+	 *            , <code>${2}</code>, etc.
+	 */
+	public static String replaceParameters(String string, Object... replParams) {
+		String replString = null;
+		for (int i = 0; i < replParams.length; i++) {
+			replString = replParams[i] != null ? replParams[i].toString() : "null";
+			// Problem with replacement of '$' sign in
+			// replace string, so first quote these characters
+			// in the replacement
+			replString = Matcher.quoteReplacement(replString);
+			// Perform the "real" replacement for the ${..}
+			string = string.replaceAll("\\$\\{" + i + "\\}", replString);
+		}
+		return string;
+	}
+
 }



More information about the Schmitzm-commits mailing list