Java - Time difference in minutes

后端 未结 4 1196
不思量自难忘°
不思量自难忘° 2021-01-21 11:12

I have this problem with calculating time difference in minutes. Its working fine with exampples like calculating the difference between 2045 and 2300.

But when I want t

4条回答
  •  忘掉有多难
    2021-01-21 11:49

    You can add if statement to check if this is today, and if no you can add one day to this, since you are comparing time it wont be problem if you add full day

        if(d2.before(d1)){
            d2.setTime(d2.getTime()+86400000);
        }
    

    Try it out

提交回复
热议问题