class HerdDateUtils extends DateUtils {

    public static String formatDuration(long duration)
    {
        // Initialize the result string.
        StringBuilder result = new StringBuilder();

        // Since we have to display the readable duration, append it initially.

        long remainingDuration = duration;

        // If the duration is 0, then just return 0 milliseconds.
        if (remainingDuration == 0)
        {
            result.append("0 Milliseconds");
        }
        else
        {
            // Compute each duration separately.
            remainingDuration = processDuration(remainingDuration, MILLIS_PER_DAY, "Day", result, false);
            remainingDuration = processDuration(remainingDuration, MILLIS_PER_HOUR, "Hour", result, false);
            remainingDuration = processDuration(remainingDuration, MILLIS_PER_MINUTE, "Minute", result, false);
            remainingDuration = processDuration(remainingDuration, MILLIS_PER_SECOND, "Second", result, false);

            // Compute the milliseconds.
            long milliSeconds = remainingDuration;
            if (milliSeconds > 0)
            {
                // Just display the final millisecond portion no matter what (i.e. the duration is 1).
                processDuration(remainingDuration, 1, "Millisecond", result, true);
            }
        }

        // Return the result.
        return result.toString();
    }

}