Please follow the below steps to resolve your issue
1. create a below class containing 2 variables
Class A
{
datetime sTime;---will hold start time
Datetime eTime;--will hold end time
}
2. Declare below variables.
--considering below input for explanation
StartTime=9:00AM; --should be datetime
EndTime=5:00PM;--should be datetime
SlotDuration=10minutes;--int
interval = 30 min;--int
3. Loop through till end time
while (StartTime<=EndTime)
{
A objA=new A()--create instance of class created in step1
A.sTime=starttime;
a.eTime=Datetime.add(starttime+slotDuration);--add start time and slotDuration to get endtime
--Add object into list
list.add(a);
starttime=dattime.add(starttime+intervaltime)
}
4. while displaying merge like startime + '-'+endtime;
Hope it will resolve your issue.
Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator