youdevise/java-statsd-client — pull request #13 by jonbartels (2014-05-22 16:31:17+00:00)
Title: Create a stopTimer method to take a start time, calculate the runtime to...

Create a stopTimer method to take a start time, calculate the runtime to now(), and safely cast that time.

My team added this method to a wrapper for our project. We found ourselves doing this frequently:
long startTime = System.currentTimeMillis();
//our code
//record our stat using Google Ints to safely cast the long to an int
myStatsDClient.recordExecutionTime("mystat", Ints.saturatedCast(System.currentTimeMillis() - startTime);

It seems rare, but possible that the current time minus the start time could exceed the min and max values for int.

PS - my first ever pull request. If I did it wrong hit me with a newspaper and I'll fix it!