Package com.logicaldoc.util.time
Class TimeDiff
- java.lang.Object
-
- com.logicaldoc.util.time.TimeDiff
-
public class TimeDiff extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimeDiff.TimeField
-
Constructor Summary
Constructors Constructor Description TimeDiff()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long[]
getTimeDifference(long t1, long t2)
Calculate the absolute difference between two dates without regard for time offsetsstatic long[]
getTimeDifference(Date d1, Date d2)
Calculate the absolute difference between two Date without regard for time offsetsstatic long
getTimeDifference(Date d1, Date d2, TimeDiff.TimeField field)
Calculate the absolute difference between two Date without regard for time offsetsstatic void
printDiffs(long[] diffs)
static String
printDuration(long diffMillis)
Prints the duration in the format HH:MM:ss.SSSstatic String
printDuration(Date start, Date stop)
-
-
-
Method Detail
-
getTimeDifference
public static long getTimeDifference(Date d1, Date d2, TimeDiff.TimeField field)
Calculate the absolute difference between two Date without regard for time offsets- Parameters:
d1
- Date oned2
- Date twofield
- The field we're interested in out of day, hour, minute, second, millisecond- Returns:
- The value of the required field
-
getTimeDifference
public static long[] getTimeDifference(long t1, long t2)
Calculate the absolute difference between two dates without regard for time offsets- Parameters:
t1
- Date one expressed in milliscondst2
- Date two expressed in millisconds- Returns:
- The fields day, hour, minute, second and millisecond
-
getTimeDifference
public static long[] getTimeDifference(Date d1, Date d2)
Calculate the absolute difference between two Date without regard for time offsets- Parameters:
d1
- Date oned2
- Date two- Returns:
- The fields day, hour, minute, second and millisecond
-
printDuration
public static String printDuration(long diffMillis)
Prints the duration in the format HH:MM:ss.SSS- Parameters:
diffMillis
- Duration expressed in milliseconds- Returns:
- The formatted output
-
printDiffs
public static void printDiffs(long[] diffs)
-
-