Question: how to calculate difference between two times in java?
Answer: getTime() - d1. getTime(); long diffSeconds = diff / 1000; long diffMinutes = diff / (60 * 1000); long diffHours = diff / (60 * 60 * 1000); System. out. println("Time in seconds: " + diffSeconds + " seconds."); System.