Skip to content
Snippets Groups Projects
Commit 025dc2a1 authored by brinn's avatar brinn
Browse files

Improve rendering with DateTimeUtils.renderDuration for durations which are full hours.

SVN: 28172
parent 91a2519b
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,13 @@ public final class DateTimeUtils
}
long minutes = durationInMinutes % 60;
long hours = durationInMinutes / 60;
return render(hours, "h") + " " + render(minutes, "min");
if (minutes > 0)
{
return render(hours, "h") + " " + render(minutes, "min");
} else
{
return render(hours, "h");
}
}
private static String render(long value, String unit)
......
......@@ -44,7 +44,7 @@ public class DateTimeUtilsTest extends AssertJUnit
assertEquals("2min", DateTimeUtils.renderDuration(100 * 1000));
assertEquals("42min", DateTimeUtils.renderDuration(42 * 1000 * 60));
assertEquals("59min", DateTimeUtils.renderDuration(59 * 1000 * 60));
assertEquals("1h 0min", DateTimeUtils.renderDuration(60 * 1000 * 60));
assertEquals("1h", DateTimeUtils.renderDuration(60 * 1000 * 60));
assertEquals("1h 1min", DateTimeUtils.renderDuration(61 * 1000 * 60));
assertEquals("2h 3min", DateTimeUtils.renderDuration(123 * 1000 * 60));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment