How to check if the difference between 2 dates is more than 20 minutes

Use

if (now.getTime() - previous.getTime() >= 20*60*1000) {
    ...
}

Or, more verbose, but perhaps slightly easier to read:

import static java.util.concurrent.TimeUnit.*;

...

long MAX_DURATION = MILLISECONDS.convert(20, MINUTES);

long duration = now.getTime() - previous.getTime();

if (duration >= MAX_DURATION) {
    ...
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)