Package gaiasky.util.gaia.time
Class NanoSecs
java.lang.Object
gaiasky.util.gaia.time.ConcreteDuration
gaiasky.util.gaia.time.NanoSecs
- All Implemented Interfaces:
Duration,java.io.Serializable
public class NanoSecs extends ConcreteDuration implements java.io.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:
- Serialized Form
-
Field Summary
Fields inherited from class gaiasky.util.gaia.time.ConcreteDuration
valueFields inherited from interface gaiasky.util.gaia.time.Duration
DAYS_PER_JULIAN_YEAR, HOURS_PER_DAY, HOURS_PER_JULIAN_YEAR, HOURS_PER_REV, MINS_PER_DAY, MINS_PER_HOUR, MINS_PER_JULIAN_YEAR, MINS_PER_REV, NS_PER_DAY, NS_PER_DAY_L, NS_PER_HOUR, NS_PER_HOUR_L, NS_PER_JULIAN_YEAR, NS_PER_JULIAN_YEAR_L, NS_PER_MIN, NS_PER_MIN_L, NS_PER_REV, NS_PER_REV_L, NS_PER_SEC, REVS_PER_DAY, REVS_PER_JULIAN_YEAR, SECS_PER_DAY, SECS_PER_HOUR, SECS_PER_JULIAN_YEAR, SECS_PER_MIN, SECS_PER_REV -
Constructor Summary
-
Method Summary
Modifier and Type Method Description Durationadd(Duration d)Add a duration to this onedoubleasDays()static doubleasDays(long nanoSecs)doubleasHours()static doubleasHours(long nanoSecs)doubleasJulianYears()static doubleasJulianYears(long nanoSecs)doubleasMins()static doubleasMins(long nanoSecs)longasNanoSecs()doubleasRevs()static doubleasRevs(long nanoSecs)doubleasSecs()static doubleasSecs(long nanoSecs)NanoSecsclone()Durationmult(double s)Multiply this duration by a given factorNanoSecsnegate()Durationset(Duration d)Set this duration to a new given oneDurationsub(Duration d)Subtract a duration from this oneMethods inherited from class gaiasky.util.gaia.time.ConcreteDuration
getScale, isLongerThan, setScaleMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
NanoSecs
public NanoSecs()Default constructor -
NanoSecs
public NanoSecs(long ns)Construct object from number of nano seconds.- Parameters:
ns- [ns]
-
-
Method Details
-
set
Description copied from interface:DurationSet this duration to a new given one- Specified by:
setin interfaceDuration- Parameters:
d- duration to set this one to- Returns:
- updated object
- See Also:
Duration.set(Duration)
-
asNanoSecs
public long asNanoSecs()- Specified by:
asNanoSecsin interfaceDuration- Returns:
- duration expressed in ns
- See Also:
Duration.asNanoSecs()
-
asSecs
public double asSecs()- Specified by:
asSecsin interfaceDuration- Returns:
- duration expressed in s
- See Also:
Duration.asSecs()
-
asSecs
public static double asSecs(long nanoSecs)- Parameters:
nanoSecs-- Returns:
- nanoSecs expressed in s
-
asMins
public double asMins()- Specified by:
asMinsin interfaceDuration- Returns:
- duration expressed in min
- See Also:
Duration.asMins()
-
asMins
public static double asMins(long nanoSecs)- Parameters:
nanoSecs-- Returns:
- nanoSecs expressed in mins
-
asHours
public double asHours()- Specified by:
asHoursin interfaceDuration- Returns:
- duration expressed in h
- See Also:
Duration.asHours()
-
asRevs
public double asRevs()- Specified by:
asRevsin interfaceDuration- Returns:
- duration expressed in revolutions
- See Also:
Duration.asRevs()
-
asDays
public double asDays()- Specified by:
asDaysin interfaceDuration- Returns:
- number of ns expressed days
- See Also:
Duration.asDays()
-
asJulianYears
public double asJulianYears()- Specified by:
asJulianYearsin interfaceDuration- Returns:
- duration expressed in Julian years
- See Also:
Duration.asJulianYears()
-
negate
- Specified by:
negatein interfaceDuration- Overrides:
negatein classConcreteDuration- Returns:
- negated amount of time
- See Also:
Duration.negate()
-
add
Description copied from interface:DurationAdd a duration to this one- Specified by:
addin interfaceDuration- Parameters:
d- amount of time to add- Returns:
- updated object
- See Also:
Duration.add(Duration)
-
sub
Description copied from interface:DurationSubtract a duration from this one- Specified by:
subin interfaceDuration- Parameters:
d- amount of time to subtract- Returns:
- updated object
- See Also:
Duration.sub(Duration)
-
mult
Description copied from interface:DurationMultiply this duration by a given factor- Specified by:
multin interfaceDuration- Overrides:
multin classConcreteDuration- Parameters:
s- scale factor- Returns:
- updated object
- See Also:
ConcreteDuration.mult(double)
-
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.
-
clone
- Overrides:
clonein classjava.lang.Object- See Also:
Object.clone()
-