Package gaiasky.util.gaia.time
Interface Duration
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ConcreteDuration
,Days
,Hours
,JulianYears
,Mins
,NanoSecs
,Revs
,Secs
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.-
Field Summary
Modifier and TypeFieldDescriptionstatic double
static double
static double
static double
static double
static double
static double
static double
static double
static long
static double
static long
static double
static long
static double
static long
static double
static long
static long
A few obvious constantsstatic double
static double
static double
static double
static double
static double
static double
-
Method Summary
Modifier and TypeMethodDescriptionAdd a duration to this onedouble
asDays()
double
asHours()
double
double
asMins()
long
double
asRevs()
double
asSecs()
getScale()
boolean
isLongerThan(Duration d)
Check that this duration is longer than a given onemult(double s)
Multiply this duration by a given factornegate()
Set this duration to a new given onevoid
Set the time scale for this durationSubtract a duration from this one
-
Field Details
-
NS_PER_SEC
static final long NS_PER_SECA 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 Details
-
set
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
Add a duration to this one- Parameters:
d
- amount of time to add- Returns:
- updated object
-
sub
Subtract a duration from this one- Parameters:
d
- amount of time to subtract- Returns:
- updated object
-
isLongerThan
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
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
Set the time scale for this duration- Parameters:
scale
- time scale to set the duration to
-