Java两次之间的区别

时间:2010-12-31 10:14:05

标签: java time

  

可能重复:
  Calculating the Difference Between Two Java Date Instances

time1:17:05 time2:17:08

我想在几秒钟内得到差异。

2 个答案:

答案 0 :(得分:7)

 long diffInMillis =    newerDate.getTime() - olderDate.getTime()

必须参加

答案 1 :(得分:0)

使用Date Class

long diffInSec =    (newerDate.getTime() - olderDate.getTime())/1000;