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;
  }