### Question:
CronUtils { public static Date getExpirationTime(Date startTime, CycleEnum cycleEnum) { Date maxExpirationTime = null; Date startTimeMax = null; try { startTimeMax = getEndTime(startTime); Calendar calendar = Calendar.getInstance(); calendar.setTime(startTime); switch (cycleEnum) { case HOUR: calendar.add(Calendar.HOUR, 1); break; case DAY: calendar.add(Calendar.DATE, 1); break; case WEEK: calendar.add(Calendar.DATE, 1); break; case MONTH: calendar.add(Calendar.DATE, 1); break; default: logger.error("Dependent process definition's cycleEnum is {},not support!!", cycleEnum); break; } maxExpirationTime = calendar.getTime(); } catch (Exception e) { logger.error(e.getMessage(),e); } return DateUtils.compare(startTimeMax,maxExpirationTime)?maxExpirationTime:startTimeMax; } private  CronUtils(); static Cron parse2Cron(String cronExpression); static CronExpression parse2CronExpression(String cronExpression); static CycleEnum getMaxCycle(Cron cron); static CycleEnum getMiniCycle(Cron cron); static CycleEnum getMaxCycle(String crontab); static List<Date> getFireDateList(Date startTime, Date endTime, CronExpression cronExpression); static List<Date> getSelfFireDateList(Date startTime, Date endTime, CronExpression cronExpression,int fireTimes); static List<Date> getSelfFireDateList(Date startTime, Date endTime, CronExpression cronExpression); static List<Date> getSelfFireDateList(Date startTime, Date endTime, String cron); static Date getExpirationTime(Date startTime, CycleEnum cycleEnum);  }### Answer:
@Test public void getExpirationTime(){ Date startTime = DateUtils.stringToDate("2020-02-07 18:30:00"); Date expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.HOUR); Assert.assertEquals("2020-02-07 19:30:00", DateUtils.dateToString(expirationTime)); expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.DAY); Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime)); expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.WEEK); Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime)); expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.MONTH); Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime)); expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.YEAR); Assert.assertEquals("2020-02-07 18:30:00", DateUtils.dateToString(expirationTime)); }