2

Possible Duplicate:
Calculating the Difference Between Two Java Date Instances

time1: 17:05 time2: 17:08

I'd like to get the difference in seconds.

1
  • 1
    Hopefully, internet does not yet exist in the timespace continuum. Elsewhere, I guess copy/pasting question title in google/bing/duckduckgo would bring you an anwser. Commented Dec 31, 2010 at 10:19

2 Answers 2

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

Must See

Sign up to request clarification or add additional context in comments.

1 Comment

You can also use: long diffInMillis = newerDate.getTimeInMillis() - olderDate.getTimeInMillis()
1

Use the Date Class

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.