class ScheduleUtil {
    private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleUtil.class);

    private static final String COLLECT_TIME_FORMAT = "yyyyMMddHHmm";
    private static final String DATE_FORMAT = "yyyyMMdd";

    /**
     * cron表达式：每分钟，根据appId计算分钟的秒数
     *
     * @param appId
     * @return
     */
    public static String getMinuteCronByAppId(long appId) {
        String baseCron = (appId % 50) + " 0/1 * ? * *";
        return baseCron;
    }
    
    public static String getMachineStatsCron(long hostId) {
        String baseCron = (hostId % 50) + " 0/" + ConstUtils.MACHINE_STATS_CRON_MINUTE + " * ? * *";
        return baseCron;
    }
    
    public static String getFiveMinuteCronByHostId(long hostId) {
        String baseCron = (hostId % 50) + " 0/5 * ? * *";
        return baseCron;
    }
    
    public static String getRedisSlowLogCron(long appId) {
        Random random = new Random();
        String baseCron = random.nextInt(60) + " 0/20 * ? * *";
        return baseCron;
    }

    /**
     * cron表达式：每小时，根据hostId计算小时的分钟数
     *
     * @param hostId
     * @return
     */
    public static String getHourCronByHostId(long hostId) {
        String hourCron = "0 %s 0/1 ? * *";
        Random random = new Random();
        long minute = (hostId + random.nextInt(Integer.MAX_VALUE)) % 60;
        return String.format(hourCron, minute);
    }

    /**
     * 计算前一分钟的时间，并格式化
     *
     * @param collectTime 基准时间
     * @return
     */
    public static long getLastCollectTime(long collectTime) {<FILL_FUNCTION_BODY>}

    /**
     * 格式化时间
     *
     * @param date
     * @return
     */
    public static long getCollectTime(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(COLLECT_TIME_FORMAT);
        return Long.parseLong(simpleDateFormat.format(date));
    }

    /**
     * 返回某一天的起始时间，如：201406300000
     *
     * @param date  当前日期
     * @param offset 针对当前日期的偏移
     * @return 日期的long形式，如201406300000
     */
    public static long getBeginTimeOfDay(Date date, int offset) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_YEAR, offset);
        date = calendar.getTime();
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
        return Long.parseLong(dateFormat.format(date) + "0000");
    }
}

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(COLLECT_TIME_FORMAT);
        try {
            Date date = simpleDateFormat.parse(String.valueOf(collectTime));
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(Calendar.MINUTE, -1);
            Date lastDate = calendar.getTime();
            return Long.parseLong(simpleDateFormat.format(lastDate));
        } catch (ParseException e) {
            LOGGER.error(e.getMessage(), e);
            return 0L;
        }
    
<no_super_class>