I'm doing a fairly simple calculation to compute the difference in Business Hours between two DateTimes. This is largely functional, but in the case of short differences (~10 minutes) this gets rounded down to 0. For example, if using a Long value representing 9 minutes (3300000), the following will get rounded to zero:
public static Double diffInBusinessHours(DateTime startTime, DateTime endTime, Id businessHoursId){
Long diffInMilliseconds = BusinessHours.diff(businessHoursId,startTime,endTime);
Double diffInBusinessHours = diffInMilliseconds/(1000*3600); //gets rounded to 0.0
return diffInBusinessHours;
}
while this will correctly return 0.9166666666666666:
public static Double diffInBusinessHours(DateTime startTime, DateTime endTime, Id businessHoursId){
Long diffInMilliseconds = BusinessHours.diff(businessHoursId,startTime,endTime);
Double diffInBusinessSeconds = diffInMilliseconds/1000;
Double diffInBusinessHours = diffInBusinessSeconds/3600;
return diffInBusinessHours;
}
Why is this happening?