Android Java : How to subtract two times?

后端 未结 5 1051
滥情空心
滥情空心 2020-12-15 08:56

I use some kind of stopwatch in my project and I have

start time ex: 18:40:10 h
stop time  ex: 19:05:15 h

I need a result from those two

5条回答
  •  醉梦人生
    2020-12-15 09:37

    Assuming you are using java.util.Date:

    long totalTime = endDate.getTime() - startDate.getTime();
    

    The result will be the total time in milliseconds.

提交回复
热议问题