Class NanoSecs

All Implemented Interfaces:
Duration, Serializable

public class NanoSecs extends ConcreteDuration implements Serializable
A finite number of nanoseconds.

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.

See Also:
  • Constructor Details

    • NanoSecs

      public NanoSecs()
      Default constructor
    • NanoSecs

      public NanoSecs(long ns)
      Construct object from number of nano seconds.
      Parameters:
      ns - [ns]
  • Method Details

    • asSecs

      public static double asSecs(long nanoSecs)
      Parameters:
      nanoSecs -
      Returns:
      nanoSecs expressed in s
    • asMins

      public static double asMins(long nanoSecs)
      Parameters:
      nanoSecs -
      Returns:
      nanoSecs expressed in mins
    • asHours

      public static double asHours(long nanoSecs)
      Parameters:
      nanoSecs -
      Returns:
      nanoSecs expressed in hours
    • asRevs

      public static double asRevs(long nanoSecs)
      Parameters:
      nanoSecs -
      Returns:
      nanoSecs expressed in revs
    • asDays

      public static double asDays(long nanoSecs)
      Parameters:
      nanoSecs - the time in nanoseconds to convert.
      Returns:
      nanoSecs expressed in days.
    • asJulianYears

      public static double asJulianYears(long nanoSecs)
      Parameters:
      nanoSecs - the time in nanoseconds to convert.
      Returns:
      nanoSecs expressed in years.
    • set

      public Duration set(Duration d)
      Description copied from interface: Duration
      Set this duration to a new given one
      Specified by:
      set in interface Duration
      Parameters:
      d - duration to set this one to
      Returns:
      updated object
      See Also:
    • asNanoSecs

      public long asNanoSecs()
      Specified by:
      asNanoSecs in interface Duration
      Returns:
      duration expressed in ns
      See Also:
    • asSecs

      public double asSecs()
      Specified by:
      asSecs in interface Duration
      Returns:
      duration expressed in s
      See Also:
    • asMins

      public double asMins()
      Specified by:
      asMins in interface Duration
      Returns:
      duration expressed in min
      See Also:
    • asHours

      public double asHours()
      Specified by:
      asHours in interface Duration
      Returns:
      duration expressed in h
      See Also:
    • asRevs

      public double asRevs()
      Specified by:
      asRevs in interface Duration
      Returns:
      duration expressed in revolutions
      See Also:
    • asDays

      public double asDays()
      Specified by:
      asDays in interface Duration
      Returns:
      number of ns expressed days
      See Also:
    • asJulianYears

      public double asJulianYears()
      Specified by:
      asJulianYears in interface Duration
      Returns:
      duration expressed in Julian years
      See Also:
    • negate

      public NanoSecs negate()
      Specified by:
      negate in interface Duration
      Overrides:
      negate in class ConcreteDuration
      Returns:
      negated amount of time
      See Also:
    • add

      public Duration add(Duration d)
      Description copied from interface: Duration
      Add a duration to this one
      Specified by:
      add in interface Duration
      Parameters:
      d - amount of time to add
      Returns:
      updated object
      See Also:
    • sub

      public Duration sub(Duration d)
      Description copied from interface: Duration
      Subtract a duration from this one
      Specified by:
      sub in interface Duration
      Parameters:
      d - amount of time to subtract
      Returns:
      updated object
      See Also:
    • mult

      public Duration mult(double s)
      Description copied from interface: Duration
      Multiply this duration by a given factor
      Specified by:
      mult in interface Duration
      Overrides:
      mult in class ConcreteDuration
      Parameters:
      s - scale factor
      Returns:
      updated object
      See Also:
    • clone

      public NanoSecs clone()
      Overrides:
      clone in class Object
      See Also: