I have the following function:
public static int getDiffHour(Date first) {
int hoursBetween = Hours.hoursBetween(new LocalDate(first), new LocalDate()).getHours();
return hoursBetween;
}
I am trying to get difference in hours between two dates.
Here is my Traceview:
The function is taking crazy amounts of time and resource to execute - what do I miss here. My service is getting killed on 5.0.1 due to this enormous CPU time taken by this function.
Edit:
Digging down deeper, I find that 99% of the CPU time is taken by LocalDate init. Is there a way I can avoid that and supply a date precalculated?