Calculating time difference with start time and elapsed time
<pre><code>public static final long TIMEOUT = 60000;
public static final long SYSTEM_TIME = System.currentTimeMillis();
</code></pre>

<p>I have the TIMEOUT Value for my application set as 60000 and i have my system time. Now how would i know that <code>50 seconds</code> has been elapsed and i need to show a message to the end-user.</p>

<pre><code>if (TIMEOUT  - SYSTEM_TIME &lt;= 10000) {
    Toast.makeText(getApplicationContext(), "10 Seconds Left", Toast.LENGTH_LONG).show();
    disconnectHandler.postDelayed(disconnectCallback, DISCONNECT_TIMEOUT);
}
</code></pre>
