I am working on the BusinessHours and I am getting the below error. I just want to calculate the no. of hours difference between MondayStartTime
and MondayEndTime
Method does not exist or incorrect signature: [BusinessHours].diff(Id, Time, Time)
The code which I used
BusinessHours bh = [SELECT FridayEndTime,FridayStartTime,Id,IsActive,IsDefault,LastModifiedById,
LastModifiedDate,MondayEndTime,MondayStartTime,Name,SaturdayEndTime,
SaturdayStartTime,SundayEndTime,SundayStartTime,SystemModstamp,ThursdayEndTime,
ThursdayStartTime,TimeZoneSidKey,TuesdayEndTime,TuesdayStartTime,
WednesdayEndTime,WednesdayStartTime FROM BusinessHours where Name='XXX Hours'
LIMIT 1];
System.debug('bh.MondayStartTime :: '+bh.MondayStartTime);
System.debug('bh.MondayEndTime :: '+bh.MondayEndTime);
System.debug('-------------------------------------------------------------');
Datetime MondayStartDT = Datetime.newInstance(Date.Today(), bh.MondayStartTime);
System.debug('MondayStartDT :: '+MondayStartDT);
Datetime MondayEndDT = Datetime.newInstance(Date.Today(), bh.MondayEndTime);
System.debug('MondayEndDT :: '+MondayEndDT);
Long diff = BusinessHours.diff(bh.Id, MondayStartDT, MondayEndDT);
System.debug('diff :: '+diff);
Edit: As per thatherahere code I am getting following output I dont see its calculating the diff correctly.
Now Updated