Class TimeDiff


  • public class TimeDiff
    extends Object
    • Constructor Detail

      • TimeDiff

        public TimeDiff()
    • Method Detail

      • main

        public static void main​(String[] args)
      • 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 one
        d2 - Date two
        field - 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​(Date d1,
                                               Date d2)
        Calculate the absolute difference between two Date without regard for time offsets
        Parameters:
        d1 - Date one
        d2 - Date two
        Returns:
        The fields day, hour, minute, second and millisecond
      • printDuration

        public static String printDuration​(Date start,
                                           Date stop)
      • 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)