Apache Commons has the DurationFormatUtils class for applying a specified format to a time duration. So, something like:
long time = System.currentTimeMillis();
//do something that takes some time...
long completedIn = System.currentTimeMillis() - time;
DurationFormatUtils.formatDuration(completedIn, "HH:mm:ss:SS");