Class DurationUtils

java.lang.Object
org.moeaframework.util.DurationUtils

public class DurationUtils extends Object
Utility for converting a Duration into primitives.
  • Method Details

    • isGreaterThanOrEqual

      public static final boolean isGreaterThanOrEqual(Duration lhs, Duration rhs)
      Returns true if the left-hand side is greater than or equal to the right-hand side duration.
      Parameters:
      lhs - the left-hand side
      rhs - the right-hand side
      Returns:
      true if greater than or equal; false otherwise
    • toPercentage

      public static final double toPercentage(Duration elapsed, Duration total)
      Returns the percentage as a value between 0.0 and 100.0 showing the percent complete.
      Parameters:
      elapsed - the elasped time
      total - the total time
      Returns:
      the percentage
    • toSeconds

      public static final double toSeconds(Duration duration)
      Converts the given duration into fractional seconds.
      Parameters:
      duration - the duration
      Returns:
      the duration in seconds
    • toMilliseconds

      public static final long toMilliseconds(Duration duration)
      Converts the given duration into milliseconds.
      Parameters:
      duration - the duration
      Returns:
      the duration in milliseconds
    • toNanoseconds

      public static final long toNanoseconds(Duration duration)
      Converts the given duration into nanoseconds.
      Parameters:
      duration - the duration
      Returns:
      the duration in nanoseconds
    • format

      public static final String format(Duration duration)
      Produces a ISO 8601 duration format in the form hh:mm:ss.
      Parameters:
      duration - the duration
      Returns:
      the formatted string
    • formatHighResolution

      public static final String formatHighResolution(Duration duration)
      Produces a higher-resolution format string in the form ss.mmmm "s".
      Parameters:
      duration - the duration
      Returns:
      the formatted string