Package com.anylogic.engine
@AnyLogicInternalAPI public interface UtilitiesCommon
Various utilities, e.g. date calculations.
- Author:
- AnyLogic North America, LLC https://anylogic.com
Modifier and Type | Method | Description |
---|---|---|
static long | addToDate |
Returns the date, which will be after the given
amount
of timeUnit s from the given datee.g. |
static void | dropTime |
Sets the given calendar to the time
00:00:00.000 |
static Date | dropTime |
This utility method drops time-of-the-day information and returns
the
date with the time 00:00:00.000 |
static long | getDateWithTimeNextTo |
Returns the date which the next date after the given
date
and has the specified time (in the default time zone) |
@AnyLogicInternalAPI static Date dropTime(Date date, Calendar context)
This utility method drops time-of-the-day information and returns
the
date
with the time 00:00:00.000
- Parameters:
date
- the datecontext
-Calendar
instance used for computations. Locale/TimeZone defined there matter. Will become dirty after this method is called.- Returns:
- the
date
with the time00:00:00.000
@AnyLogicInternalAPI static void dropTime(Calendar c)
Sets the given calendar to the time
00:00:00.000
- Parameters:
c
- the calendar to change
@AnyLogicInternalAPI static long addToDate(long dateInMillis, int timeUnit, double amount, Calendar context)
Returns the date, which will be after the given
e.g.
Note, that this method correctly handles leap years, daylight saving time tweaks, e.g. its ( DAY, 1 ) may actually add to the date 23 or 25 hours during DST switch, in order to get the correct result
amount
of timeUnit
s from the given datee.g.
addToDate( DAY, 1 )
returns the 'tomorrow' date:
( date + 1 day )
Note, that this method correctly handles leap years, daylight saving time tweaks, e.g. its ( DAY, 1 ) may actually add to the date 23 or 25 hours during DST switch, in order to get the correct result
- Parameters:
dateInMillis
- the base datetimeUnit
- time unit, possible values:Calendar.YEAR
Calendar.MONTH
Calendar#WEEK
Calendar#DAY
Calendar.HOUR
Calendar.MINUTE
Calendar.SECOND
Calendar.MILLISECOND
amount
- the number of time units (may be negative - in this case the returned date will be in the past relative to the givendate
)context
-Calendar
instance used for computations. Locale/TimeZone defined there matter. Will become dirty after this method is called.- Returns:
- the new date obtained by adding
amount
oftimeUnit
s to the givendate
@AnyLogicInternalAPI static long getDateWithTimeNextTo(long dateMillis, int hourOfDay, int minute, int second, Calendar context)
Returns the date which the next date after the given
date
and has the specified time (in the default time zone)- Parameters:
dateMillis
- the datehourOfDay
- the hour of day (using 24-hour clock)minute
- the minutesecond
- the secondcontext
-Calendar
instance used for computations. Locale/TimeZone defined there matter. Will become dirty after this method is called.- Returns:
- the
date
with the given time