I have to find the difference in time between two different date objects in java and if that time exceeds 5 sec i have to invalidate the session.
Here\'s the scenari
long difference = date2.getTime() - date1.getTime(); // now you have your answer in milliseconds - //so divide by 1000 to get the time in seconds