Java finding difference between times

前端 未结 4 1865
感情败类
感情败类 2020-12-20 06:10

i have some problem while finding difference between times, if i try to find difference in todays time (say t1 = \"08:00:00\" and t2 = \"10:00:00\" then it is giving correct

4条回答
  •  没有蜡笔的小新
    2020-12-20 06:42

    See some options here

    such as :

         LocalDate today = LocalDate.now()
         LocalDate yeasterday = today.minusDays(1);
         Duration oneDay = Duration.between(today, yesterday);
         Duration.between(today.atTime(0, 0), yesterday.atTime(0, 0)).toDays()   // another option
    

提交回复
热议问题