From 9f339c357f5fc482b40552db3d3a305bf509cba9 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 31 Oct 2018 14:25:42 +0100 Subject: [PATCH] negative time in TimeUtil --- .../fr/pandacube/java/util/measurement/TimeUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/pandacube/java/util/measurement/TimeUtil.java b/src/main/java/fr/pandacube/java/util/measurement/TimeUtil.java index 9483c15..d9b2c9c 100644 --- a/src/main/java/fr/pandacube/java/util/measurement/TimeUtil.java +++ b/src/main/java/fr/pandacube/java/util/measurement/TimeUtil.java @@ -2,6 +2,8 @@ package fr.pandacube.java.util.measurement; public class TimeUtil { public static String durationToString(long msec_time, boolean dec_seconde) { + boolean neg = msec_time < 0; + msec_time = Math.abs(msec_time); int j = 0, h = 0, m = 0, s = 0; long msec = msec_time; @@ -25,8 +27,11 @@ public class TimeUtil { } if (result.equals("")) result = "0"; - - return result.trim(); + result = result.trim(); + if (neg) + result = "-" + result; + + return result; } public static String durationToString(long msec_time) {