Skip to content

Instantly share code, notes, and snippets.

@sujee
Created August 25, 2011 00:41
Show Gist options
  • Save sujee/1169675 to your computer and use it in GitHub Desktop.
Save sujee/1169675 to your computer and use it in GitHub Desktop.
hadoop utilities : StringUtils 3 : format time
System.out.println ("1000000 ms = " + StringUtils.formatTime(1000000));
long t1 = System.currentTimeMillis();
// execute a command
long t2 = System.currentTimeMillis();
t2 += 10000000; // adjust for this demo
System.out.println ("operation took : " + StringUtils.formatTimeDiff(t2, t1));
/* output:
1000000 ms = 16mins, 40sec
operation took : 2hrs, 46mins, 40sec
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment