negative time in TimeUtil

This commit is contained in:
Marc Baloup 2018-10-31 14:25:42 +01:00
parent d46d0d2890
commit 9f339c357f

View File

@ -2,6 +2,8 @@ package fr.pandacube.java.util.measurement;
public class TimeUtil { public class TimeUtil {
public static String durationToString(long msec_time, boolean dec_seconde) { 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; int j = 0, h = 0, m = 0, s = 0;
long msec = msec_time; long msec = msec_time;
@ -25,8 +27,11 @@ public class TimeUtil {
} }
if (result.equals("")) result = "0"; if (result.equals("")) result = "0";
result = result.trim();
return result.trim(); if (neg)
result = "-" + result;
return result;
} }
public static String durationToString(long msec_time) { public static String durationToString(long msec_time) {