public static String getFormattedTimeWithDiff(DateFormat dateFormat,
                                                long finishTime, long startTime){
    StringBuilder buf = new StringBuilder();
    if (0 != finishTime) {
      buf.append(dateFormat.format(new Date(finishTime)));
      if (0 != startTime){
        buf.append(" (" + formatTimeDiff(finishTime , startTime) + ")");
      }
    }
    return buf.toString();
  }
Formats time in ms and appends difference (finishTime - startTime)
as returned by formatTimeDiff().
If finish time is 0, empty string is returned, if start time is 0
then difference is not appended to return value.
@param dateFormat date format to use
@param finishTime finish time
@param startTime start time
@return formatted value.
common/src/java/org/apache/hive/common/util/HiveStringUtils.java