Java Code Examples for org.joda.time.Period#getMillis()

The following examples show how to use org.joda.time.Period#getMillis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThirdEyeUtils.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * Guess time duration from period.
 *
 * @param granularity dataset granularity
 * @return
 */
public static int getTimeDuration(Period granularity) {
  if (granularity.getDays() > 0) {
    return granularity.getDays();
  }
  if (granularity.getHours() > 0) {
    return granularity.getHours();
  }
  if (granularity.getMinutes() > 0) {
    return granularity.getMinutes();
  }
  if (granularity.getSeconds() > 0) {
    return granularity.getSeconds();
  }
  return granularity.getMillis();
}
 
Example 2
Source File: FutureAction.java    From FlareBot with MIT License 5 votes vote down vote up
public FutureAction(long guildId, long channelId, long responsible, long target, String content,
                    Period delay, Action action) {
    this.guildId = guildId;
    this.channelId = channelId;
    this.responsible = responsible;
    this.target = target;
    this.content = content;
    this.delay = delay;
    this.created = new DateTime(DateTimeZone.UTC);
    this.expires = created.plus(delay);
    this.action = action;

    if (delay.getMillis() <= 0)
        delete();
}
 
Example 3
Source File: Grouping.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private static DateTime makeOrigin(DateTime first, Period period) {
  if (period.getYears() > 0) {
    return first.year().roundFloorCopy().toDateTime();

  } else if (period.getMonths() > 0) {
    return first.monthOfYear().roundFloorCopy().toDateTime();

  } else if (period.getWeeks() > 0) {
    return first.weekOfWeekyear().roundFloorCopy().toDateTime();

  } else if (period.getDays() > 0) {
    return first.dayOfYear().roundFloorCopy().toDateTime();

  } else if (period.getHours() > 0) {
    return first.hourOfDay().roundFloorCopy().toDateTime();

  } else if (period.getMinutes() > 0) {
    return first.minuteOfHour().roundFloorCopy().toDateTime();

  } else if (period.getSeconds() > 0) {
    return first.secondOfMinute().roundFloorCopy().toDateTime();

  } else if (period.getMillis() > 0) {
    return first.millisOfSecond().roundFloorCopy().toDateTime();

  }

  throw new IllegalArgumentException(String.format("Unsupported Period '%s'", period));
}
 
Example 4
Source File: DateUtilities.java    From Bats with Apache License 2.0 4 votes vote down vote up
public static int periodToMillis(final Period period){
  return (period.getHours() * hoursToMillis) +
         (period.getMinutes() * minutesToMillis) +
         (period.getSeconds() * secondsToMillis) +
         (period.getMillis());
}
 
Example 5
Source File: JodaDateUtility.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static int millisFromPeriod(final Period period) {
  return (period.getHours() * hoursToMillis) +
    (period.getMinutes() * minutesToMillis) +
    (period.getSeconds() * secondsToMillis) +
    (period.getMillis());
}