Issue
I am using the compareTo method in Java to try and check if a certain date is greater than or equal than 24 hours after another date.
How do I determine what integer to compare the date to?
Solution
Answer depends on what you want to achieve.
One way, could be checking difference in milliseconds. 24 h in milliseconds can be calculated via
24 * 60 * 60 * 1000 = 86400000
h min sec millis
(in code you can also write TimeUnit.HOURS.toMillis(24)
which IMO is more readable)
So now you can just check if difference between two dates (expressed in milliseconds) is greater than 86400000.
Answered By - Pshemo
Answer Checked By - Robin (JavaFixing Admin)