Current milliseconds, from long to int
<p>I currently have the following code:</p>

<pre><code>public static int currentTimeMillis()
{
    long millisLong = System.currentTimeMillis();
    while ( millisLong &gt; Integer.MAX_VALUE )
    {
        millisLong -= Integer.MAX_VALUE;
    }
    return (int)millisLong;
}
</code></pre>

<p>which returns the current time in an <code>int</code> format (not exactly, but it can be used for time differences). For very good reasons, I can't use <code>long</code>. </p>

<p>Yes, I am just interested in the difference between two calls, and this approach works well. But it just looks wrong. I know that. And inefficient. I know. So my questions is, how can I improve it?</p>

<p>I need a function that returns an <code>int</code> such that:</p>

<pre><code>int x1 = currentTimeMillis(); //my function
long y1 = System.currentTimeMillis();

.....

int x2 = currentTimeMillis();
long y2 = System.currentTimeMillis();

// here, x2 - x1 must be equal to y2 - y1
</code></pre>

<p>EDIT:</p>

<p>FYI, I want to do this for benchmarking. I'm running tests on multiple threads in parallel, the stop event is triggered by an external component. I'm also serializing the data in a way that only supports <code>int</code>, and the object I'm serializing can not have <code>long</code> members. </p>
