class 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();

}