How to calculate the difference between two dates in java


long diffInMilleseconds = end.getTime() – start.getTime();
// end and start are timestamps

long noofdays=diffInMilleseconds/86400000;
long diffInSeconds = diffInMilleseconds/1000;
long diffInMinutes = diffInSeconds/60;
long diffInHours = diffInMinutes/60;
long diffInDays = diffInHours/24;

Related Posts: