Package gaiasky.util.gaia.time
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.SerializableADurationrepresents 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.
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDAYS_PER_JULIAN_YEARstatic doubleHOURS_PER_DAYstatic doubleHOURS_PER_JULIAN_YEARstatic doubleHOURS_PER_REVstatic doubleMINS_PER_DAYstatic doubleMINS_PER_HOURstatic doubleMINS_PER_JULIAN_YEARstatic doubleMINS_PER_REVstatic doubleNS_PER_DAYstatic longNS_PER_DAY_Lstatic doubleNS_PER_HOURstatic longNS_PER_HOUR_Lstatic doubleNS_PER_JULIAN_YEARstatic longNS_PER_JULIAN_YEAR_Lstatic doubleNS_PER_MINstatic longNS_PER_MIN_Lstatic doubleNS_PER_REVstatic longNS_PER_REV_Lstatic longNS_PER_SECA few obvious constantsstatic doubleREVS_PER_DAYstatic doubleREVS_PER_JULIAN_YEARstatic doubleSECS_PER_DAYstatic doubleSECS_PER_HOURstatic doubleSECS_PER_JULIAN_YEARstatic doubleSECS_PER_MINstatic doubleSECS_PER_REV
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Durationadd(Duration d)Add a duration to this onedoubleasDays()doubleasHours()doubleasJulianYears()doubleasMins()longasNanoSecs()doubleasRevs()doubleasSecs()TimeScalegetScale()booleanisLongerThan(Duration d)Check that this duration is longer than a given oneDurationmult(double s)Multiply this duration by a given factorDurationnegate()Durationset(Duration d)Set this duration to a new given onevoidsetScale(TimeScale scale)Set the time scale for this durationDurationsub(Duration d)Subtract a duration from this one
-
-
-
Field Detail
-
NS_PER_SEC
static final long NS_PER_SEC
A few obvious constants- See Also:
- Constant Field Values
-
SECS_PER_MIN
static final double SECS_PER_MIN
- See Also:
- Constant Field Values
-
MINS_PER_HOUR
static final double MINS_PER_HOUR
- See Also:
- Constant Field Values
-
HOURS_PER_DAY
static final double HOURS_PER_DAY
- See Also:
- Constant Field Values
-
DAYS_PER_JULIAN_YEAR
static final double DAYS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
HOURS_PER_REV
static final double HOURS_PER_REV
- See Also:
- Constant Field Values
-
REVS_PER_DAY
static final double REVS_PER_DAY
- See Also:
- Constant Field Values
-
REVS_PER_JULIAN_YEAR
static final double REVS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
HOURS_PER_JULIAN_YEAR
static final double HOURS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
MINS_PER_JULIAN_YEAR
static final double MINS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
SECS_PER_JULIAN_YEAR
static final double SECS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
NS_PER_JULIAN_YEAR
static final double NS_PER_JULIAN_YEAR
- See Also:
- Constant Field Values
-
NS_PER_JULIAN_YEAR_L
static final long NS_PER_JULIAN_YEAR_L
- See Also:
- Constant Field Values
-
MINS_PER_DAY
static final double MINS_PER_DAY
- See Also:
- Constant Field Values
-
SECS_PER_DAY
static final double SECS_PER_DAY
- See Also:
- Constant Field Values
-
NS_PER_DAY
static final double NS_PER_DAY
- See Also:
- Constant Field Values
-
NS_PER_DAY_L
static final long NS_PER_DAY_L
- See Also:
- Constant Field Values
-
MINS_PER_REV
static final double MINS_PER_REV
- See Also:
- Constant Field Values
-
SECS_PER_REV
static final double SECS_PER_REV
- See Also:
- Constant Field Values
-
NS_PER_REV
static final double NS_PER_REV
- See Also:
- Constant Field Values
-
NS_PER_REV_L
static final long NS_PER_REV_L
- See Also:
- Constant Field Values
-
SECS_PER_HOUR
static final double SECS_PER_HOUR
- See Also:
- Constant Field Values
-
NS_PER_HOUR
static final double NS_PER_HOUR
- See Also:
- Constant Field Values
-
NS_PER_HOUR_L
static final long NS_PER_HOUR_L
- See Also:
- Constant Field Values
-
NS_PER_MIN
static final double NS_PER_MIN
- See Also:
- Constant Field Values
-
NS_PER_MIN_L
static final long NS_PER_MIN_L
- See Also:
- Constant Field Values
-
-
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:
trueif this duration is longer thand
-
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
-
-