I have two Date objects and I need to get the time difference so I can determine the total hours between them. They happen to be from the same day. The result I would like w
Here's simple way:
private static int hoursDifference(Date date1, Date date2) { final int MILLI_TO_HOUR = 1000 * 60 * 60; return (int) (date1.getTime() - date2.getTime()) / MILLI_TO_HOUR; }