commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1573762 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
Date Mon, 03 Mar 2014 21:36:17 GMT
Author: sebb
Date: Mon Mar  3 21:36:16 2014
New Revision: 1573762

URL: http://svn.apache.org/r1573762
Log:
Don't assign parameter; use the work field

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java?rev=1573762&r1=1573761&r2=1573762&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
Mon Mar  3 21:36:16 2014
@@ -119,7 +119,7 @@ public class DurationFormatUtils {
      * @param padWithZeros  whether to pad the left hand side of numbers with 0's
      * @return the formatted duration, not null
      */
-    public static String formatDuration(long durationMillis, final String format, final boolean
padWithZeros) {
+    public static String formatDuration(final long durationMillis, final String format, final
boolean padWithZeros) {
 
         final Token[] tokens = lexx(format);
 
@@ -127,26 +127,23 @@ public class DurationFormatUtils {
         long hours        = 0;
         long minutes      = 0;
         long seconds      = 0;
-        long milliseconds = 0;
+        long milliseconds = durationMillis;
         
         if (Token.containsTokenWithValue(tokens, d) ) {
-            days = durationMillis / DateUtils.MILLIS_PER_DAY;
-            durationMillis = durationMillis - (days * DateUtils.MILLIS_PER_DAY);
+            days = milliseconds / DateUtils.MILLIS_PER_DAY;
+            milliseconds = milliseconds - (days * DateUtils.MILLIS_PER_DAY);
         }
         if (Token.containsTokenWithValue(tokens, H) ) {
-            hours = durationMillis / DateUtils.MILLIS_PER_HOUR;
-            durationMillis = durationMillis - (hours * DateUtils.MILLIS_PER_HOUR);
+            hours = milliseconds / DateUtils.MILLIS_PER_HOUR;
+            milliseconds = milliseconds - (hours * DateUtils.MILLIS_PER_HOUR);
         }
         if (Token.containsTokenWithValue(tokens, m) ) {
-            minutes = durationMillis / DateUtils.MILLIS_PER_MINUTE;
-            durationMillis = durationMillis - (minutes * DateUtils.MILLIS_PER_MINUTE);
+            minutes = milliseconds / DateUtils.MILLIS_PER_MINUTE;
+            milliseconds = milliseconds - (minutes * DateUtils.MILLIS_PER_MINUTE);
         }
         if (Token.containsTokenWithValue(tokens, s) ) {
-            seconds = durationMillis / DateUtils.MILLIS_PER_SECOND;
-            durationMillis = durationMillis - (seconds * DateUtils.MILLIS_PER_SECOND);
-        }
-        if (Token.containsTokenWithValue(tokens, S) ) {
-            milliseconds = durationMillis;
+            seconds = milliseconds / DateUtils.MILLIS_PER_SECOND;
+            milliseconds = milliseconds - (seconds * DateUtils.MILLIS_PER_SECOND);
         }
 
         return format(tokens, 0, 0, days, hours, minutes, seconds, milliseconds, padWithZeros);



Mime
View raw message