org.joda.time.PeriodType#hours ( )源码实例Demo

下面列出了org.joda.time.PeriodType#hours ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: org-java   文件: OrgDateTimeUtils.java
private static PeriodType getPeriodType(OrgInterval.Unit unit) {
    switch (unit) {
        case HOUR:
            return PeriodType.hours();
        case DAY:
            return PeriodType.days();
        case WEEK:
            return PeriodType.weeks();
        case MONTH:
            return PeriodType.months();
        case YEAR:
            return PeriodType.years();
        default:
            throw new IllegalArgumentException("Unknown unit " + unit);
    }
}
 
源代码2 项目: incubator-pinot   文件: ConfigUtils.java
/**
 * Helper for heuristically parsing period unit from config (e.g. 'millis', 'hour', 'd')
 *
 * @param type period type string
 * @return PeriodType
 */
static PeriodType parsePeriodType(String type) {
  type = type.toLowerCase();

  if (type.startsWith("y") || type.startsWith("a")) {
    return PeriodType.years();
  }
  if (type.startsWith("mo")) {
    return PeriodType.months();
  }
  if (type.startsWith("w")) {
    return PeriodType.weeks();
  }
  if (type.startsWith("d")) {
    return PeriodType.days();
  }
  if (type.startsWith("h")) {
    return PeriodType.hours();
  }
  if (type.startsWith("s")) {
    return PeriodType.seconds();
  }
  if (type.startsWith("mill") || type.startsWith("ms")) {
    return PeriodType.millis();
  }
  if (type.startsWith("m")) {
    return PeriodType.minutes();
  }

  throw new IllegalArgumentException(String.format("Invalid period type '%s'", type));
}
 
源代码3 项目: incubator-pinot   文件: BaselineAggregate.java
/**
 * Returns an instance of BaselineAggregate for the specified type and {@code numDays} offsets
 * computed on a consecutive day-over-day basis starting with a lag of {@code offsetHours}.
 * <br/><b>NOTE:</b> this will <b>NOT</b> apply DST correction
 *
 * @see BaselineAggregateType
 *
 * @param type aggregation type
 * @param numHours number of consecutive weeks
 * @param offsetHours lag for starting consecutive weeks
 * @param timeZone time zone
 * @return BaselineAggregate with given type and daily offsets
 */
public static BaselineAggregate fromHourOverHour(BaselineAggregateType type, int numHours, int offsetHours, DateTimeZone timeZone) {
  List<Period> offsets = new ArrayList<>();
  for (int i = 0; i < numHours; i++) {
    offsets.add(new Period(0, 0, 0, 0, -1 * (i + offsetHours), 0, 0, 0, PeriodType.hours()));
  }
  return new BaselineAggregate(type, offsets, timeZone, PeriodType.hours());
}