Check if 24 hours have passed (reading from a string)

后端 未结 4 1941
醉话见心
醉话见心 2021-01-28 04:37

I am saving date\'s in a file in the following format as a string.

Sat Jul 21 23:31:55 EDT 2012

How can I check if 24 hours have passed? I am a

4条回答
  •  我在风中等你
    2021-01-28 05:06

    I am not sure if I completely understood the question - do you have two dates for comparison or do you wish to keep checking periodically if 24 hours have elapsed? If comparing two date/times, I would suggest looking at joda or perhaps date4j. Using joda, one could look into using interval between two dates:

    Interval interval = new Interval(previousTime, new Instant());
    

    where previous time would be the time you mentioned

提交回复
热议问题