public static String getDuration(long diff) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(new Date(diff));
        StringBuffer s = new StringBuffer();
        if (calendar.get(Calendar.HOUR) > 1) {
            s.append("hours: " + (calendar.get(Calendar.HOUR) - 1) + ", ");
        }
        if (calendar.get(Calendar.MINUTE) > 0) {
            s.append("minutes: " + (calendar.get(Calendar.MINUTE)) + ", ");
        }
        if (calendar.get(Calendar.SECOND) > 0) {
            s.append("seconds: " + (calendar.get(Calendar.SECOND)) + ", ");
        }
        if (calendar.get(Calendar.MILLISECOND) > 1) {
            s.append("milliseconds: " + (calendar.get(Calendar.MILLISECOND)) + ", ");
        }
        s.append("total milliseconds: " + diff);
        return s.toString();
    }
public static String getDuration ( long diff ) { GregorianCalendar calendar = new GregorianCalendar ( ) ; calendar . setTime ( new Date ( diff ) ) ; StringBuffer s = new StringBuffer ( ) ; if ( calendar . get ( Calendar . HOUR ) > 1 ) { s . append ( "hours: " + ( calendar . get ( Calendar . HOUR ) - 1 ) + ", " ) ; } if ( calendar . get ( Calendar . MINUTE ) > 0 ) { s . append ( "minutes: " + ( calendar . get ( Calendar . MINUTE ) ) + ", " ) ; } if ( calendar . get ( Calendar . SECOND ) > 0 ) { s . append ( "seconds: " + ( calendar . get ( Calendar . SECOND ) ) + ", " ) ; } if ( calendar . get ( Calendar . MILLISECOND ) > 1 ) { s . append ( "milliseconds: " + ( calendar . get ( Calendar . MILLISECOND ) ) + ", " ) ; } s . append ( "total milliseconds: " + diff ) ; return s . toString ( ) ; }
Returns a String reporting the time passed during a given number of milliseconds.

@param  diff  A time span in milliseconds
@return       A human readable representation of a timespan given in milliseconds