Difference in days between two dates in Java?

后端 未结 19 1969
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 08:26

I need to find the number of days between two dates: one is from a report and one is the current date. My snippet:

  int age=calculateDiffer         


        
19条回答
  •  不知归路
    2020-11-22 08:43

    It depends on what you define as the difference. To compare two dates at midnight you can do.

    long day1 = ...; // in milliseconds.
    long day2 = ...; // in milliseconds.
    long days = (day2 - day1) / 86400000;
    

提交回复
热议问题