public static String formatTime(long time) {
        time /= 1000;
        String seconds = Long.toString(time % 60) + "s";
        if (time < 60) {
            return seconds;
        }
        String minutes = Long.toString((time % 3600) / 60) + "m ";
        if (time < 3600) {
            return minutes + seconds;
        }

        String hours = Long.toString((time % 86400) / 3600) + "h ";
        if (time < 86400) {
            return hours + minutes + seconds;
        }

        String days = Long.toString(time / 86400) + "d ";
        return days + hours + minutes + seconds;
    }