package de.retest.recheck.printer.leaf;

import org.apache.commons.lang3.time.DurationFormatUtils;

import de.retest.recheck.printer.Printer;
import de.retest.ui.diff.DurationDifference;

public class DurationDifferencePrinter implements Printer<DurationDifference> {

	private static final String SECONDS_FORMAT = "ss.SSS";
	private static final String SECONDS_SUFFIX = " s";

	@Override
	public String toString( final DurationDifference difference, final String indent ) {
		final long actual = (long) difference.getActual();
		final long expected = (long) difference.getExpected();
		if (actual < expected) { // format can't handle negative values
			return indent + "-" + format( expected - actual );
		}
		return indent + format( actual - expected );
	}

	private static String format( final long duration ) {
		return DurationFormatUtils.formatDuration( duration, SECONDS_FORMAT, false ) + SECONDS_SUFFIX;
	}
}

@@ -584,16 +584,17 @@
 ;%0A%09%09if (
+ 
 actual %3C
@@ -602,16 +602,17 @@
 expected
+ 
 ) %7B // f
@@ -810,16 +810,73 @@
 ion ) %7B%0A
+%09%09// TODO Unobfuscate DurationUtil and then use it here.%0A
 %09%09return

Add TODO note