public static String durationString(long periodMs) {
        StringBuilder bld = new StringBuilder();
        Duration duration = Duration.ofMillis(periodMs);
        long hours = duration.toHours();
        if (hours > 0) {
            bld.append(hours).append("h");
            duration = duration.minusHours(hours);
        }
        long minutes = duration.toMinutes();
        if (minutes > 0) {
            bld.append(minutes).append("m");
            duration = duration.minusMinutes(minutes);
        }
        long seconds = duration.getSeconds();
        if ((seconds != 0) || bld.toString().isEmpty()) {
            bld.append(seconds).append("s");
        }
        return bld.toString();
    }
Pretty-print a duration.

@param periodMs      The duration in milliseconds.
@return              A human-readable duration string.
trogdor/src/main/java/org/apache/kafka/trogdor/common/StringFormatter.java