diff options
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r-- | src/org/traccar/helper/UnitsConverter.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/org/traccar/helper/UnitsConverter.java b/src/org/traccar/helper/UnitsConverter.java index 56d15e4e7..3dd435df4 100644 --- a/src/org/traccar/helper/UnitsConverter.java +++ b/src/org/traccar/helper/UnitsConverter.java @@ -23,6 +23,8 @@ public final class UnitsConverter { private static final double KNOTS_TO_CPS_RATIO = 0.0194384449; private static final double METERS_TO_FEET_RATIO = 0.3048; private static final double METERS_TO_MILE_RATIO = 1609.34; + private static final long MILLISECONDS_TO_HOURS_RATIO = 3600000; + private static final long MILLISECONDS_TO_MINUTES_RATIO = 60000; private UnitsConverter() { } @@ -71,4 +73,16 @@ public final class UnitsConverter { return value * METERS_TO_MILE_RATIO; } + public static long msFromHours(long value) { + return value * MILLISECONDS_TO_HOURS_RATIO; + } + + public static long msFromHours(double value) { + return (long) (value * MILLISECONDS_TO_HOURS_RATIO); + } + + public static long msFromMinutes(long value) { + return value * MILLISECONDS_TO_MINUTES_RATIO; + } + } |