删除掉早于一定时间的记录
@param baseTime		从什么时间算起
@param periodBefore	多少时间之前的要删掉
@param unit			时间单位
973402
public void purge(Date baseTime, long periodBefore, TimeUnit unit) {
		purge(baseTime.getTime(), periodBefore, unit);
	}
458453
public static boolean checkValidInterval(int interval, TimeUnit unit)
    {
        if (0 >= interval || INTERVAL_MAX < interval)
        {
            return false;
        }

        switch (unit)
        {
        case HOURS:
            break;
        case MINUTES:
            break;
        case SECONDS:
            break;
        case MILLISECONDS:
            break;
        default:
            return false;
        }

        return true;
    }
783046
public long getCount(long toWhen, long period, TimeUnit unit) {
		return getCount(toWhen - TimeUnit.MILLISECONDS.convert(period, unit), toWhen);
	}
548780
public long get(final TimeUnit toUnit)
	{
		if (this.unit == toUnit)
			return period;
		else
			return toUnit.convert(period, this.unit);
	}
525620
public static ChronoUnit chronoUnit(TimeUnit unit) {
        Objects.requireNonNull(unit, "unit");
        switch (unit) {
            case NANOSECONDS:
                return ChronoUnit.NANOS;
            case MICROSECONDS:
                return ChronoUnit.MICROS;
            case MILLISECONDS:
                return ChronoUnit.MILLIS;
            case SECONDS:
                return ChronoUnit.SECONDS;
            case MINUTES:
                return ChronoUnit.MINUTES;
            case HOURS:
                return ChronoUnit.HOURS;
            case DAYS:
                return ChronoUnit.DAYS;
            default:
                throw new IllegalArgumentException("Unknown TimeUnit constant");
        }
    }
162164
public static long between(Date beginDate, Date endDate, DateUnit unit, boolean isAbs) {
		return new DateBetween(beginDate, endDate, isAbs).between(unit);
	}
360333
synchronized public void start(long initialDelay, long period, TimeUnit unit) {
        start(initialDelay, period, unit, () -> {
            try {
                report();
            } catch (Throwable ex) {
                LOG.error("Exception thrown from {}#report. Exception was suppressed.", ScheduledReporter.this.getClass().getSimpleName(), ex);
            }
        });
    }
586782
@SuppressWarnings("unchecked")
   public <UNIT extends TimeUnit> UNIT getUnit(final Class<UNIT> unitType)
   {
      if (unitType == null)
         return null;

      for (TimeUnit unit : units.keySet()) {
         if (unitType.isAssignableFrom(unit.getClass()))
         {
            return (UNIT) unit;
         }
      }
      return null;
   }
737774
public static TimeUnit getParentUnit(TimeUnit unit)
    {
        TimeUnit result = null;

        switch (unit)
        {
        case HOURS:
            result = TimeUnit.DAYS;
            break;
        case MINUTES:
            result = TimeUnit.HOURS;
            break;
        case SECONDS:
            result = TimeUnit.MINUTES;
            break;
        case MILLISECONDS:
            result = TimeUnit.SECONDS;
            break;
        case MICROSECONDS:
            result = TimeUnit.MILLISECONDS;
            break;
        case NANOSECONDS:
            result = TimeUnit.MICROSECONDS;
            break;
        default:
            break;
        }

        return result;
    }
142731
@Override
  public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder) {
    if (builder != this.builder) {
      this.builder = builder;
      reset();
    }
    return this;
  }
669161
public static long between(Date beginDate, Date endDate, DateUnit unit) {
		return between(beginDate, endDate, unit, true);
	}
732003
private Period setTimeUnitValue(TimeUnit unit, float value) {
    if (value < 0) {
      throw new IllegalArgumentException("value: " + value);
    }
    return setTimeUnitInternalValue(unit, (int)(value * 1000) + 1);
  }
1216894
public void start(long period, TimeUnit unit) {
        executor.scheduleAtFixedRate(() -> {
            try {
                report();
            } catch (RuntimeException ex) {
                LOG.error("RuntimeException thrown from {}#report. Exception was suppressed.", ScheduledReporter.this.getClass().getSimpleName(), ex);
            }
        }, period, period, unit);
    }
688241
public void modifyTimeBase(){
		String [] time_grid=new String[6];
		time_grid=normalizer.getTimeBase().split("-");
		
		String s = "";
		if(_tp.tunit[0] != -1)
			s += Integer.toString(_tp.tunit[0]);
		else
			s += time_grid[0];
		for(int i = 1; i < 6; i++){
			s += "-";
			if(_tp.tunit[i] != -1)
				s += Integer.toString(_tp.tunit[i]);
			else
				s += time_grid[i];
		}
		normalizer.setTimeBase(s);
	}
492806
@Override
    public void setUpdatePeriod(final String updatePeriod) {
        if (!PERIODS.contains(updatePeriod)) {
            throw new IllegalArgumentException("Invalid period [" + updatePeriod + "]");
        }
        this.updatePeriod = updatePeriod;
    }
59461
function preparePeriod(period, value, year) {

    var range;
    var subUnit;
    var start;
    var length;
    var unit;

    switch (period) {
      case 'year':
        unit = 'month';
        break;
      case 'month':
        unit = 'dayOfYear';
        break;
      case 'dayOfYear':
        unit = 'hourOfYear';
        break;
    }

    var result = {
      year: year,
      period: period,
      unit: unit
    };

    var utc = moment().utc();

    if (year) {
      utc.year(year);
    } else {
      year = utc.year();
    }

    if (value || value ===0) {
      utc[period](value);
    } else {
      value = utc[period]();
    }

    result.value = value;
    result.period = period;

    switch (unit) {

      case 'month':
        switch (period) {
          case 'year':
            range = _.range(12);
            break;

          default:
        }

        subUnit = 'dayOfYear';
        break;

      case 'dayOfYear':

        switch (period) {
          case 'month':
            start = utc.month(value).date(1).dayOfYear();
            length = utc.month(value).daysInMonth();

            range = _.range(start, start + length);
            break;

          default:
        }

        subUnit = 'hourOfYear';
        break;

      case 'hourOfYear':

        switch (period) {
          case 'dayOfYear':
            start = utc.dayOfYear(value).hour(0).hourOfYear();
            length = 24;

            range = _.range(start, start + length);
            break;

          default:
        }
        break;
    }

    result.subUnit = subUnit;

    if (!range) {

      var err = new Error('Could not calculate the range');
      err.statusCode = 400;
      err.code = 'NO_RANGE_SET';

      throw err;
    }

    return {
      unit: unit,
      range: range,
      year: year,
      result: result
    };

  }
15960
@Override
    public void setPeriod(int pPeriod) {
	if (pPeriod < 0) {
	    throw new IllegalArgumentException("Period cannot be negative");
	}
	int actual = Math.max(pPeriod, MIN_PERIOD);
	log.debug("Changing clock period to {}", actual);
	period = actual;

	if (isRunning()) {
	    stop();
	    start(false);
	}
    }