Interface Duration

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    ConcreteDuration, Days, Hours, JulianYears, Mins, NanoSecs, Revs, Secs

    public interface Duration
    extends java.io.Serializable
    A Duration represents an amount of time on a proper time scale. There are two implementations provided of the conversions methods one as object interface, where an object of the current class has to be instantiated. The oder implementation is provided as static class methods. Performance tests of both implementations have come up with a performance improvement of 20% of the static methods compared with the object methods.
    • Method Detail

      • set

        Duration set​(Duration d)
        Set this duration to a new given one
        Parameters:
        d - duration to set this one to
        Returns:
        updated object
      • asNanoSecs

        long asNanoSecs()
        Returns:
        duration expressed in ns
      • asSecs

        double asSecs()
        Returns:
        duration expressed in s
      • asMins

        double asMins()
        Returns:
        duration expressed in min
      • asHours

        double asHours()
        Returns:
        duration expressed in h
      • asDays

        double asDays()
        Returns:
        number of ns expressed days
      • asJulianYears

        double asJulianYears()
        Returns:
        duration expressed in Julian years
      • asRevs

        double asRevs()
        Returns:
        duration expressed in revolutions
      • negate

        Duration negate()
        Returns:
        negated amount of time
      • add

        Duration add​(Duration d)
        Add a duration to this one
        Parameters:
        d - amount of time to add
        Returns:
        updated object
      • sub

        Duration sub​(Duration d)
        Subtract a duration from this one
        Parameters:
        d - amount of time to subtract
        Returns:
        updated object
      • isLongerThan

        boolean isLongerThan​(Duration d)
        Check that this duration is longer than a given one
        Parameters:
        d - duration to compare to
        Returns:
        true if this duration is longer than d
      • mult

        Duration mult​(double s)
        Multiply this duration by a given factor
        Parameters:
        s - scale factor
        Returns:
        updated object
      • getScale

        TimeScale getScale()
        Returns:
        Current time scale of the duration
      • setScale

        void setScale​(TimeScale scale)
        Set the time scale for this duration
        Parameters:
        scale - time scale to set the duration to