public static String formatTime(long timeDiff){
  StringBuilder buf=new StringBuilder();
  long hours=timeDiff / (60 * 60 * 1000);
  long rem=(timeDiff % (60 * 60 * 1000));
  long minutes=rem / (60 * 1000);
  rem=rem % (60 * 1000);
  long seconds=rem / 1000;
  if (hours != 0) {
    buf.append(hours);
    buf.append("hrs, ");
  }
  if (minutes != 0) {
    buf.append(minutes);
    buf.append("mins, ");
  }
  buf.append(seconds);
  buf.append("sec");
  return buf.toString();
}

public static String formatTime ( long timeDiff ) { StringBuilder buf = new StringBuilder ( ) ; long hours = timeDiff / ( 60 * 60 * 1000 ) ; long rem = ( timeDiff % ( 60 * 60 * 1000 ) ) ; long minutes = rem / ( 60 * 1000 ) ; rem = rem % ( 60 * 1000 ) ; long seconds = rem / 1000 ; if ( hours != 0 ) { buf . append ( hours ) ; buf . append ( "hrs, " ) ; } if ( minutes != 0 ) { buf . append ( minutes ) ; buf . append ( "mins, " ) ; } buf . append ( seconds ) ; buf . append ( "sec" ) ; return buf . toString ( ) ; }
given the time in long milliseconds , returns a string in the format xhrs , ymins , z sec .
