I have a question in BusinessHour NextstartDate method. When I am using nextStartDate(businessHoursId, targetDate) method , I am not getting the Start time of next business day. Instead it is defaulted to 9.00AM irrespective of time zone. Any thoughts to fetch the start time of next start business day.
// Starting from the targetTime, find the next date when business hours reopens.(This is what is given in the website)
I have am having businesshours setup from 11.AM - 5.PM EST( Monday - Friday and saturday,sunday is holiday).
When I am trying to execute my code in workbench
String StrD = '2016-06-03 13:00:00';
Datetime StartDate = Datetime.valueOf(StrD);
system.debug('*StartDate*'+StartDate);
String StrDEnd = '2016-06-04 18:00:00'; // Saturday which is a holiday
Datetime EnddDate = Datetime.valueOf(StrDEnd);
system.debug('*EnddDate*'+EnddDate.format());
list<BusinessHours> businehour = [SELECT FridayEndTime,FridayStartTime,Id,IsActive,IsDefault,MondayEndTime,MondayStartTime,Name,
SaturdayEndTime,SaturdayStartTime,SundayEndTime,SundayStartTime,SystemModstamp,ThursdayEndTime,ThursdayStartTime,
TimeZoneSidKey,TuesdayEndTime,TuesdayStartTime,WednesdayEndTime,WednesdayStartTime from BusinessHours where Name ='11To5EST'];
Datetime nextStart = BusinessHours.nextStartDate(businehour[0].id, EnddDate);
system.debug('*nextStart*'+nextStart.format());
Output: *nextStart*6/6/2016 9:00 AM***
o/P:13:00:40.11 (11295030)|EXECUTION_STARTED 13:00:40.11
(11310427)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
13:00:40.11 (12093809)|USER_DEBUG|[3]|DEBUG|*StartDate*2016-06-03
18:00:00 13:00:40.11
(12259171)|USER_DEBUG|[6]|DEBUG|*EnddDate*6/4/2016 6:00 PM
***13:00:40.11 (18316761)|USER_DEBUG|[14]|DEBUG|*nextStart*6/6/2016 9:00 AM***13:00:40.11
(18357887)|CODE_UNIT_FINISHED|execute_anonymous_apex 13:00:40.11
(19679036)|EXECUTION_FINISHED