Question: how to calculate date and time difference 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.