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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 4 23:49:12 CEST 2012


Author: mojays
Date: 2012-04-04 23:49:12 +0200 (Wed, 04 Apr 2012)
New Revision: 1939

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
Log:
LangUtil.combineDate(Date,long) vereinfacht

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-04-04 21:26:53 UTC (rev 1938)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-04-04 21:49:12 UTC (rev 1939)
@@ -368,11 +368,13 @@
      *            time in milliseconds of day
      */
     public static Date combineDate(Date date, long timeMillis) {
+      int dayMillis = (int) (timeMillis % DAY_MILLIS);
       GregorianCalendar cal = new GregorianCalendar();
-      cal.set(Calendar.HOUR_OF_DAY, (int)(timeMillis/LangUtil.HOUR_MILLIS) );
-      cal.set(Calendar.MINUTE,      (int)((timeMillis%LangUtil.HOUR_MILLIS)/LangUtil.MIN_MILLIS) );
-      cal.set(Calendar.SECOND,      (int)((timeMillis%LangUtil.MIN_MILLIS)/LangUtil.SEC_MILLIS) );
-      cal.set(Calendar.MILLISECOND, (int)(timeMillis%LangUtil.SEC_MILLIS) );
+      cal.set(Calendar.HOUR_OF_DAY, 0);
+      cal.set(Calendar.MINUTE,      0);
+      cal.set(Calendar.SECOND,      0);
+      cal.set(Calendar.MILLISECOND, 0);
+      cal.add(Calendar.MILLISECOND, dayMillis);
       Date time = cal.getTime();
       return combineDate(date, time);
     }



More information about the Schmitzm-commits mailing list