Class DateBasedTimer
This class encapsulates the time of the simulation. Its purpose is that it can be
passed across objects without problem. That is,
BigDecimal
is immutable and
therefore creates a new instance for each modification.- Since:
- MaDKit 5.3
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a date-based time which value isLocalDateTime.of(1, 1, 1, 0, 0)
;DateBasedTimer
(LocalDateTime initialDate) Creates a date-based instance using a specificLocalDateTime
as starting point.DateBasedTimer
(LocalDateTime initialDate, LocalDateTime endDate) Creates a date-based instance using a specificLocalDateTime
as starting point. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds one time unit to the current date using the default unit.Gets the default temporal unit for date increments.void
incrementCurrentDate
(long amountToAdd) Increments the current date by the specified amount using the default unit.void
incrementCurrentDate
(long amountToAdd, ChronoUnit unit) Increments the current date by the specified amount and unit.void
Sets the default temporal unit for date increments.Methods inherited from class madkit.simulation.scheduler.SimuTimer
getCurrentTime, getEndTime, getStartTime, getTimeLabel, hasReachedEndTime, reset, setCurrentTime, setEndTime, setStartTime, setTimeFormat, toString
-
Constructor Details
-
DateBasedTimer
Creates a date-based instance using a specificLocalDateTime
as starting point.- Parameters:
initialDate
- aLocalDateTime
to start withendDate
- aLocalDateTime
to end with- See Also:
-
DateBasedTimer
Creates a date-based instance using a specificLocalDateTime
as starting point.- Parameters:
initialDate
- aLocalDateTime
to start with- See Also:
-
DateBasedTimer
public DateBasedTimer()Creates a date-based time which value isLocalDateTime.of(1, 1, 1, 0, 0)
;
-
-
Method Details
-
incrementCurrentDate
Increments the current date by the specified amount and unit.- Parameters:
amountToAdd
- the amount to addunit
- the unit of the amount to add
-
incrementCurrentDate
public void incrementCurrentDate(long amountToAdd) Increments the current date by the specified amount using the default unit.- Parameters:
amountToAdd
- the amount to add
-
setDefaultTemporalUnit
Sets the default temporal unit for date increments.- Parameters:
unit
- the default temporal unit
-
getDefaultTemporalUnit
Gets the default temporal unit for date increments.- Returns:
- the default temporal unit
-
addOneTimeUnit
public void addOneTimeUnit()Adds one time unit to the current date using the default unit.
-