Search in sources :

Example 26 with DateTime

use of com.google.api.ads.admanager.jaxws.v202202.DateTime in project Singularity by HubSpot.

the class RFC5545Schedule method getNextValidTime.

public Date getNextValidTime() {
    final long now = System.currentTimeMillis();
    DateTime startDateTime = new DateTime(dtStart.getYear(), (dtStart.getMonthOfYear() - 1), dtStart.getDayOfMonth(), dtStart.getHourOfDay(), dtStart.getMinuteOfHour(), dtStart.getSecondOfMinute());
    RecurrenceRuleIterator timeIterator = recurrenceRule.iterator(startDateTime);
    int count = 0;
    while (timeIterator.hasNext() && (count < MAX_ITERATIONS || (recurrenceRule.hasPart(Part.COUNT) && count < recurrenceRule.getCount()))) {
        count++;
        long nextRunAtTimestamp = timeIterator.nextMillis();
        if (nextRunAtTimestamp >= now) {
            return new Date(nextRunAtTimestamp);
        }
    }
    return null;
}
Also used : RecurrenceRuleIterator(org.dmfs.rfc5545.recur.RecurrenceRuleIterator) DateTime(org.dmfs.rfc5545.DateTime) Date(java.util.Date)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)17 Set (java.util.Set)8 Before (org.junit.Before)8 Test (org.junit.Test)8 BooleanValue (com.google.api.ads.admanager.axis.v202105.BooleanValue)3 DateTime (com.google.api.ads.admanager.axis.v202105.DateTime)3 DateTimeValue (com.google.api.ads.admanager.axis.v202105.DateTimeValue)3 DateValue (com.google.api.ads.admanager.axis.v202105.DateValue)3 NumberValue (com.google.api.ads.admanager.axis.v202105.NumberValue)3 SetValue (com.google.api.ads.admanager.axis.v202105.SetValue)3 TargetingValue (com.google.api.ads.admanager.axis.v202105.TargetingValue)2 TextValue (com.google.api.ads.admanager.axis.v202105.TextValue)2 BooleanValue (com.google.api.ads.admanager.axis.v202108.BooleanValue)2 Date (com.google.api.ads.admanager.axis.v202108.Date)2 DateTime (com.google.api.ads.admanager.axis.v202108.DateTime)2 DateTimeValue (com.google.api.ads.admanager.axis.v202108.DateTimeValue)2 DateValue (com.google.api.ads.admanager.axis.v202108.DateValue)2 NumberValue (com.google.api.ads.admanager.axis.v202108.NumberValue)2 SetValue (com.google.api.ads.admanager.axis.v202108.SetValue)2 Targeting (com.google.api.ads.admanager.axis.v202108.Targeting)2