public static String duration(final long milliseconds) {
        final long totalSeconds = milliseconds / 1000;
        final long days = totalSeconds / 86400;
        final long hours = (totalSeconds % 86400) / 3600;
        final long minutes = ((totalSeconds % 86400) % 3600) / 60;
        final long seconds = totalSeconds % 60;
        final StringBuilder sb = new StringBuilder();
        if (days > 0)sb.append(Long.toString(days)).append("d");
        if (hours > 0) sb.append((sb.length() > 0) ? " " : "").append(Long.toString(hours)).append("h");
        if (minutes > 0) sb.append((sb.length() > 0) ? " " : "").append(Long.toString(minutes)).append("m");
        if (totalSeconds != 0 && totalSeconds < 60) sb.append((sb.length() > 0) ? " " : "").append(Long.toString(seconds)).append("s");
        if (totalSeconds == 0) return "<1s";
        return sb.toString();
    }