public static String toFormatedDuration(long duration) {
        if (duration < 5 * 1000) {
            return duration + "ms";
        } else if (duration < (60 * 1000)) {
            return ((int) (duration / 1000)) + "s";
        } else if (duration < (60 * 60 * 1000)) {
            return ((int) (duration / (60 * 1000))) + "m";
        } else if (duration < (24 * 60 * 60 * 1000)) {
            return ((int) (duration / (60 * 60 * 1000))) + "h";
        } else {
            return ((long) (duration / (24 * 60 * 60 * 1000))) + "d";
        }
    }