Calculate Duration

Just use System.currentTimeMillis() to capture the time when the activity starts and stops. E.g.:

long startTime = System.currentTimeMillis();
// wait for activity here
long endTime = System.currentTimeMillis();
long seconds = (endTime - startTime) / 1000;

As of Java 8 there is more convenient way of doing this.

Instant start = Instant.now();
...
Duration.between(start, Instant.now())

Benefit of this approach is more flexible API provided by the Duration class.

https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html