Class Durations

java.lang.Object
com.helixframework.time.Durations

public final class Durations extends Object
Utility class for working with time durations.
  • Method Details

    • toHumanReadable

      public static String toHumanReadable(Duration duration)
      Converts the supplied Duration into a human-readable form like "X Days X Hours X Minutes X Seconds".
      Parameters:
      duration - duration
      Returns:
      the human-readable duration
    • toHumanReadable

      public static String toHumanReadable(Duration duration, boolean compress)
      Converts the supplied Duration into a human readable form like "X Days X Hours X Minutes X Seconds". If you specify a compressed version then it will drop any of the larger timespans that are zero (i.e. "0 Days 0 Hours 10 Minutes 20 Seconds" becomes "10 Minutes 20 Seconds")
      Parameters:
      duration - the duration to convert
      compress - if true, compresses the format
      Returns:
      the human-readable duration
    • toHumanReadableShorthand

      public static String toHumanReadableShorthand(Duration duration)
      Converts the supplied milliseconds value into a human readable shorthand form like "X D X H X M X S".
      Parameters:
      duration - duration
      Returns:
      the shorthand human-readable duration
    • toHumanReadableShorthand

      public static String toHumanReadableShorthand(Duration duration, boolean compress)
      Converts the supplied Duration into a human-readable shorthand form like "X D X H X M X S". If you specify a compressed version then it will drop any of the larger timespans that are zero (i.e. "0 D 0 H 10 M 20 S" becomes "10 M 20 S")
      Parameters:
      duration - the duration to convert
      compress - if true, compresses the format by omitting zero-value timespans
      Returns:
      a shorthand human-readable duration string
    • millisToHumanReadable

      public static String millisToHumanReadable(long millis)
      Converts the supplied milliseconds value into a human readable form like "X Days X Hours X Minutes X Seconds".
      Parameters:
      millis - milliseconds
      Returns:
      the human-readable duration
    • millisToHumanReadable

      public static String millisToHumanReadable(long millis, boolean compress)
      Converts the supplied milliseconds value into a human-readable form like "X Days X Hours X Minutes X Seconds". If you specify a compressed version then it will drop any of the larger timespans that are zero (i.e. "0 Days 0 Hours 10 Minutes 20 Seconds" becomes "10 Minutes 20 Seconds").
      Parameters:
      millis - milliseconds to convert
      compress - if true, compresses the format by omitting zero-value timespans
      Returns:
      a human-readable duration string
    • millisToHumanReadableShorthand

      public static String millisToHumanReadableShorthand(long millis)
      Converts the supplied milliseconds value into a human-readable shorthand form like "X D X H X M X S".
      Parameters:
      millis - milliseconds
      Returns:
      shorthand human-readable duration
    • millisToHumanReadableShorthand

      public static String millisToHumanReadableShorthand(long millis, boolean compress)
      Converts the supplied milliseconds value into a human-readable shorthand form like "X D X H X M X S". If you specify a compressed version then it will drop any of the larger timespans that are zero (i.e. "0 D 0 H 10 M 20 S" becomes "10 M 20 S").
      Parameters:
      millis - the milliseconds to convert
      compress - if true, compresses the format by omitting zero-value timespans
      Returns:
      a shorthand human-readable duration string
    • millisFromHumanReadable

      public static long millisFromHumanReadable(String time)
      Converts the supplied human readable time duration into milliseconds.
      Parameters:
      time - human readable time duration
      Returns:
      milliseconds