[Solved] Find difference between two timestamps [closed]


Try this method:

public static long getDateDiff(long timeUpdate, long timeNow, TimeUnit timeUnit)
{
    long diffInMillies = Math.abs(timeNow - timeUpdate);
    return timeUnit.convert(diffInMillies, TimeUnit.MILLISECONDS);
}

It gives you the difference of whatever unit (days, years, …).

long timestamp1 = 1500462813000;
long timestamp2 = System.currentTimeMillis();
long diffInDays = getDateDiff(timestamp1, timestamp2, TimeUnit.DAYS);

2

solved Find difference between two timestamps [closed]