AnyLogic
Expand
Font size

public interface UtilitiesCommon

Method Summary

Modifier and TypeMethodDescription
static longaddToDate(long dateInMillis, int timeUnit, double amount, Calendar context)
Returns the date, which will be after the given amount of timeUnits from the given date
e.g.
static voiddropTime(Calendar c)
Sets the given calendar to the time 00:00:00.000
static DatedropTime(Date date, Calendar context)
This utility method drops time-of-the-day information and returns the date with the time 00:00:00.000
static longgetDateWithTimeNextTo(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)

Method Details

dropTime

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 date
context - Calendar instance used for computations. Locale/TimeZone defined there matter. Will become dirty after this method is called.
Returns:
the date with the time 00:00:00.000

dropTime

@AnyLogicInternalAPI
static void dropTime(Calendar c)
Sets the given calendar to the time 00:00:00.000
Parameters:
c - the calendar to change

addToDate

static long addToDate(long dateInMillis,
 int timeUnit,
 double amount,
 Calendar context)
Returns the date, which will be after the given amount of timeUnits from the given date
e.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 date
timeUnit - time unit, possible values:
amount - the number of time units (may be negative - in this case the returned date will be in the past relative to the given date)
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 of timeUnits to the given date

getDateWithTimeNextTo

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 date
hourOfDay - the hour of day (using 24-hour clock)
minute - the minute
second - the second
context - 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