/*
 * Copyright 2012 JBoss Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.drools.guvnor.shared.simulation;

public class SimulationTestUtils {

    public static String formatMillis(long millis) {
        if (millis == 0L) {
            return "0";
        }
        StringBuilder millisString = new StringBuilder();
        long leftover = millis;
        if (leftover >= 86400000L) {
            millisString.append(leftover / 86400000L).append("d");
            leftover %= 86400000L;
        }
        if (leftover >= 3600000L) {
            millisString.append(leftover / 3600000L).append("h");
            leftover %= 3600000L;
        }
        if (leftover >= 60000L) {
            millisString.append(leftover / 60000L).append("m");
            leftover %= 60000L;
        }
        if (leftover >= 1000L) {
            millisString.append(leftover / 1000L).append("s");
            leftover %= 1000L;
        }
        if (leftover >= 1L) {
            millisString.append(leftover).append("ms");
        }
        return millisString.toString();
    }

    private SimulationTestUtils() {
    }

}

@@ -975,16 +975,17 @@
 ppend(%22d
+ 
 %22);%0A    
@@ -1123,16 +1123,17 @@
 ppend(%22h
+ 
 %22);%0A    
@@ -1266,16 +1266,17 @@
 ppend(%22m
+ 
 %22);%0A    
@@ -1405,16 +1405,17 @@
 ppend(%22s
+ 
 %22);%0A    
@@ -1533,16 +1533,17 @@
 pend(%22ms
+ 
 %22);%0A    
@@ -1576,16 +1576,56 @@
 sString.
+deleteCharAt(millisString.length() - 1).
 toString

add a space for readability