Question: how to calculate time difference in java in seconds?
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.