BusinessHours Class
Use the BusinessHours methods to set the business hours at which your customer support team operates.
The following are methods for BusinessHours. All methods are static.
-
add(businessHoursId, startDate, intervalMilliseconds)
Adds an interval of time from a start Datetime traversing business hours only. Returns the result Datetime in the local time zone.
-
addGmt(businessHoursId, startDate, intervalMilliseconds)
Adds an interval of milliseconds from a start Datetime traversing business hours only. Returns the result Datetime in GMT.
-
diff(businessHoursId, startDate, endDate)
Returns the difference in milliseconds between a start and end Datetime based on a specific set of business hours.
-
isWithin(businessHoursId, targetDate)
Returns
trueif the specified target date occurs within business hours. Holidays are included in the calculation. -
nextStartDate(businessHoursId, targetDate)
Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.
Adds an interval of time from a start Datetime traversing business hours only. Returns the result Datetime in the local time zone.
public static Datetime add(String businessHoursId, Datetime startDate, Long intervalMilliseconds)
-
businessHoursId:
Type: String
-
startDate:
Type: Datetime
-
intervalMilliseconds:
Type: Long Interval value should be provided in milliseconds, however time precision smaller th
an one minute is ignored.
Type: Datetime
Adds an interval of milliseconds from a start Datetime traversing business hours only. Returns the result Datetime in GMT.
public static Datetime addGmt(String businessHoursId, Datetime startDate, Long intervalMilliseconds)
Type: Datetime
Returns the difference in milliseconds between a start and end Datetime based on a specific set of business hours.
public static Long diff(String businessHoursId, Datetime startDate, Datetime endDate)
Type: Long
Returns true if the specified target date occurs within business hours. Holidays are included in the calculation.
public static Boolean isWithin(String businessHoursId, Datetime targetDate)
Type: Boolean
The following example finds whether a given time is within the default business hours.
Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.
public static Datetime nextStartDate(String businessHoursId, Datetime targetDate)
- businessHoursId: Type: String The business hours ID.
- targetDate: Type: Datetime The date used as a start date to obtain the next date.
Type: Datetime
The following example finds the next date starting from the target date when business hours reopens. If the target date is within the given business hours, the target date is returned. The returned time is in the local time zone.