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.Serializable
ADuration
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.
-
-
Field Summary
Fields Modifier and Type Field Description static double
DAYS_PER_JULIAN_YEAR
static double
HOURS_PER_DAY
static double
HOURS_PER_JULIAN_YEAR
static double
HOURS_PER_REV
static double
MINS_PER_DAY
static double
MINS_PER_HOUR
static double
MINS_PER_JULIAN_YEAR
static double
MINS_PER_REV
static double
NS_PER_DAY
static long
NS_PER_DAY_L
static double
NS_PER_HOUR
static long
NS_PER_HOUR_L
static double
NS_PER_JULIAN_YEAR
static long
NS_PER_JULIAN_YEAR_L
static double
NS_PER_MIN
static long
NS_PER_MIN_L
static double
NS_PER_REV
static long
NS_PER_REV_L
static long
NS_PER_SEC
A few obvious constantsstatic double
REVS_PER_DAY
static double
REVS_PER_JULIAN_YEAR
static double
SECS_PER_DAY
static double
SECS_PER_HOUR
static double
SECS_PER_JULIAN_YEAR
static double
SECS_PER_MIN
static double
SECS_PER_REV
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Duration
add(Duration d)
Add a duration to this onedouble
asDays()
double
asHours()
double
asJulianYears()
double
asMins()
long
asNanoSecs()
double
asRevs()
double
asSecs()
TimeScale
getScale()
boolean
isLongerThan(Duration d)
Check that this duration is longer than a given oneDuration
mult(double s)
Multiply this duration by a given factorDuration
negate()
Duration
set(Duration d)
Set this duration to a new given onevoid
setScale(TimeScale scale)
Set the time scale for this durationDuration
sub(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:
true
if 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
-
-