Interface Timeable
- All Known Subinterfaces:
Agent
- All Known Implementing Classes:
Engine
,GraphAgent
,LongAgent
,LongAgentTail
,Model
,StateMachine
,Train
public interface Timeable
Interface containing convenience methods for recalculations between
simulation time and simulation calendar dates. The recalculation is based on
the two assumptions:
The zero simulation time corresponds to the specified begin date - an
instance of The one unit of simulation time corresponds to the specified time unit -
an instance of
LocalDateTime
ChronoUnit
- Author:
- Andrey Malykhanov
-
Method Summary
Modifier and TypeMethodDescriptionReturns the begin date, i.e.default double
dateToTime
(LocalDateTime date) Converts the specified date of simulation calendar to the corresponding simulation timestatic double
dateToTime
(LocalDateTime date, LocalDateTime baseDate, ChronoUnit timeUnit) Converts the specified date of simulation calendar to the corresponding simulation timedefault double
dateToTime
(Date date) Converts the specified date of simulation calendar to the corresponding simulation time.default double
day()
Returns the duration of one day of simulation calendar in simulation time units.default double
duration
(ChronoUnit chronoUnit) Returns the estimated duration of the specified period unit in simulation time units.default double
hour()
Returns the duration of one hour of simulation calendar in simulation time unitsdefault double
minute()
Returns the duration of one minute of simulation calendar in simulation time unitsstatic Timeable
of
(LocalDateTime beginDate, ChronoUnit timeUnit) Returns an instance ofTimeable
with the specified begin date and time unitdefault double
second()
Returns the duration of one second of simulation calendar in simulation time unitsdefault LocalDateTime
timeToDate
(double time) Converts the specified simulation time to corresponding date of simulation calendarstatic LocalDateTime
timeToDate
(double time, LocalDateTime beginDate, ChronoUnit timeUnit) Converts the specified simulation time to corresponding date of simulation calendartimeUnit()
Returns the simulation time unit, i.e.default double
week()
Returns the duration of one week of simulation calendar in simulation time units.default List
<LocalDateTime> wholeDays
(double tillTime) Returns the list ofLocalDateTime
instances corresponding to instants having whole days between the time 0, inclusively, and the specified time, exclusivelydefault List
<LocalDateTime> wholeDays
(double beginTime, double endTime) Returns the list ofLocalDateTime
instances corresponding to instants having whole days between the specified simulation timesdefault List
<LocalDateTime> wholeHours
(double tillTime) Returns the list ofLocalDateTime
instances corresponding to instants having whole hours between the time 0, inclusively, and the specified time, exclusivelydefault List
<LocalDateTime> wholeHours
(double beginTime, double endTime) Returns the list ofLocalDateTime
instances corresponding to instants having whole hours between the specified simulation timesdefault List
<LocalDateTime> wholeUnits
(LocalDateTime beginDate, LocalDateTime endDate, ChronoUnit unit) Returns the list ofLocalDateTime
instances corresponding to instants having whole specified period units between the specified dates
-
Method Details
-
beginDate
LocalDateTime beginDate()Returns the begin date, i.e. the simulation date that corresponds to zero simulation time- Returns:
- simulation date that corresponding to zero simulation time
-
timeUnit
ChronoUnit timeUnit()Returns the simulation time unit, i.e. period unit that corresponds to one unit of simulation time- Returns:
- period unit that corresponds to one unit of simulation time
-
second
default double second()Returns the duration of one second of simulation calendar in simulation time units- Returns:
- duration of one second of simulation calendar in simulation time units
-
minute
default double minute()Returns the duration of one minute of simulation calendar in simulation time units- Returns:
- duration of one minute of simulation calendar in simulation time units
-
hour
default double hour()Returns the duration of one hour of simulation calendar in simulation time units- Returns:
- duration of one hour of simulation calendar in simulation time units
-
day
default double day()Returns the duration of one day of simulation calendar in simulation time units. Duration of all days is always equal to 24 hours- Returns:
- duration of one day of simulation calendar in simulation time units
-
week
default double week()Returns the duration of one week of simulation calendar in simulation time units. Duration of any week is always equal to 7 days, or 7 * 24 = 168 hours- Returns:
- duration of one week of simulation calendar in simulation time units
-
duration
Returns the estimated duration of the specified period unit in simulation time units. The duration is calculated according to the rules described in the comments to this JDK method:ChronoUnit.getDuration()
.Note that when expressing durations of long periods the following rules are used:
- 1 week = 7.0 days
- 1 month = 30.436875 days
- 1 year = 365.2425 days
- 1 decade = 10.0 years = 3652.425 days
- Parameters:
chronoUnit
- specified period unit- Returns:
- estimated duration of the specified period unit in simulation time units
-
timeToDate
Converts the specified simulation time to corresponding date of simulation calendar- Parameters:
time
- specified simulation time. Can be zero, positive or negative. Must not benull
orDouble.NaN
- Returns:
- simulation date that corresponds to the specified simulation time
-
dateToTime
Converts the specified date of simulation calendar to the corresponding simulation time- Parameters:
date
- specified simulation date- Returns:
- simulation time that corresponds to the specified simulation date
-
dateToTime
Converts the specified date of simulation calendar to the corresponding simulation time. The date is specified as instance ofDate
- Parameters:
date
- specified simulation date- Returns:
- simulation time that corresponds to the specified simulation date
-
dateToTime
Converts the specified date of simulation calendar to the corresponding simulation time- Parameters:
date
- specified simulation datebaseDate
- zero date, i.e. date corresponding to zero simulation timetimeUnit
- simulation time unit- Returns:
- simulation time that corresponds to the specified simulation date
-
timeToDate
Converts the specified simulation time to corresponding date of simulation calendar- Parameters:
time
- specified simulation time. Can be zero, positive or negative. Must not benull
orDouble.NaN
beginDate
- zero date, i.e. date corresponding to zero simulation timetimeUnit
- simulation time unit- Returns:
- simulation time that corresponds to the specified simulation date
-
wholeUnits
default List<LocalDateTime> wholeUnits(LocalDateTime beginDate, LocalDateTime endDate, ChronoUnit unit) Returns the list ofLocalDateTime
instances corresponding to instants having whole specified period units between the specified dates- Parameters:
beginDate
- begin date, inclusivelyendDate
- end date, exclusivelyunit
- instance ofChronoUnit
specifying the period units of wholeness- Returns:
- list of
LocalDateTime
instances corresponding to instants having whole specified period units
-
wholeHours
Returns the list ofLocalDateTime
instances corresponding to instants having whole hours between the specified simulation times- Parameters:
beginTime
- begin time, inclusivelyendTime
- end time, exclusively- Returns:
- list of
LocalDateTime
instances corresponding to instants having whole hours between the specified simulation times
-
wholeHours
Returns the list ofLocalDateTime
instances corresponding to instants having whole hours between the time 0, inclusively, and the specified time, exclusively- Parameters:
tillTime
- specified time, exclusively- Returns:
- list of
LocalDateTime
instances corresponding to instants having whole hours between the specified simulation times
-
wholeDays
Returns the list ofLocalDateTime
instances corresponding to instants having whole days between the specified simulation times- Parameters:
beginTime
- begin time, inclusivelyendTime
- end time, exclusively- Returns:
- list of
LocalDateTime
instances corresponding to instants having whole days between the specified simulation times
-
wholeDays
Returns the list ofLocalDateTime
instances corresponding to instants having whole days between the time 0, inclusively, and the specified time, exclusively- Parameters:
tillTime
- specified time, exclusively- Returns:
- list of
LocalDateTime
instances corresponding to instants having whole days between the specified simulation times
-
of
Returns an instance ofTimeable
with the specified begin date and time unit- Parameters:
beginDate
- specified begin datetimeUnit
- specified time unit- Returns:
- instance of
Timeable
with the specified begin date and time unit
-