Esempio n. 1
0
  private boolean judgeCurrentInConfigRange(Config config) {
    long ruleStartTime;
    long ruleEndTime;
    long nowTime = (System.currentTimeMillis() + 8 * 60 * 60 * 1000) % (24 * 60 * 60 * 1000);

    try {
      ruleStartTime = buildMillsByString(config.getStarttime());
      ruleEndTime = buildMillsByString(config.getEndtime()) + ONE_MINUTE_MILLSEC;
    } catch (Exception ex) {
      ruleStartTime = 0L;
      ruleEndTime = 86400000L;
    }

    if (nowTime < ruleStartTime || nowTime > ruleEndTime) {
      return false;
    }

    return true;
  }
Esempio n. 2
0
  private boolean judgeCurrentInConfigRange(Config config) {
    long ruleStartTime;
    long ruleEndTime;
    Calendar cal = Calendar.getInstance();
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);
    int nowTime = hour * 60 * 60 * 1000 + minute * 60 * 1000;

    try {
      ruleStartTime = buildMillsByString(config.getStarttime());
      ruleEndTime = buildMillsByString(config.getEndtime());
    } catch (Exception ex) {
      ruleStartTime = 0L;
      ruleEndTime = 86400000L;
    }

    if (nowTime < ruleStartTime || nowTime > ruleEndTime) {
      return false;
    }

    return true;
  }
Esempio n. 3
0
  private Pair<Integer, List<Condition>> queryCheckMinuteAndConditions(List<Config> configs) {
    int maxMinute = 0;
    List<Condition> conditions = new ArrayList<Condition>();
    Iterator<Config> iterator = configs.iterator();

    while (iterator.hasNext()) {
      Config config = iterator.next();

      if (judgeCurrentInConfigRange(config)) {
        List<Condition> tmpConditions = config.getConditions();
        conditions.addAll(tmpConditions);

        for (Condition con : tmpConditions) {
          int tmpMinute = con.getMinute();

          if (tmpMinute > maxMinute) {
            maxMinute = tmpMinute;
          }
        }
      }
    }
    return new Pair<Integer, List<Condition>>(maxMinute, conditions);
  }