Package org.joda.time

Examples of org.joda.time.DateTime.plus()


    DateTime now = start;
    int val = 1;
    while (!now.isAfter(end.plusDays(1))) {
      aggregateCounterRepository.increment(counterName, val++, now);
      now = now.plus(Duration.standardDays(1));
    }
    long[] counts = aggregateCounterRepository.getCounts(counterName, new Interval(start, end), AggregateCountResolution.day).getCounts();
    assertEquals(67, counts.length);

    for (int i=0; i < counts.length; i++) {
View Full Code Here


    DateTime now = new DateTime();
    C last;

    synchronized (this) {
      if (eventCounters.isEmpty() || !now.isBefore(eventCounters.getLast().getEnd())) {
        addEventCounter(nextCounter(now, now.plus(maxChunkLength)));
      }

      last = eventCounters.getLast();
    }
View Full Code Here

    GaugeCounter last;

    synchronized (this) {
      if (getMostRecentCounter() == null ||
          !now.isBefore(getMostRecentCounter().getEnd())) {
        addEventCounter(nextCounter(now, now.plus(getMaxChunkLength())));
      }
      last = getMostRecentCounter();
    }
    last.add(delta, nsamples);
  }
View Full Code Here

   
    if (type == null) {
      // unix epoch for the timezone.
      DateTime startOfTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, instant.getZone());
      long intervalStart = ((instant.getMillis() - startOfTime.getMillis()) / length) * length;
      return startOfTime.plus(intervalStart);
    } else {
      return type.getTimeIntervalStart(
        instant,
        length
      );
View Full Code Here

    if(split.length == 2) {
      Period period = periodformatter.parsePeriod(split[1]);
      // calculate the timestamps for the cycles
      for (int i = 0; i < r; i++) {
        baseTime = baseTime.plus(period);
        result.add(baseTime.getMillis());
      }
    }
   
    // we have start or end date
View Full Code Here

   * @return time to fire time stamp in millis
   */
  public static long calculateTimeToFireForDuration(long now, String isoDate) {
    DateTime dateTime = new DateTime(now);
    Period period = periodformatter.parsePeriod(isoDate);
    dateTime = dateTime.plus(period);
    return dateTime.getMillis();
  }
 
  /**
   * Convenient method to calculate the duration based on the
View Full Code Here

   * @param agentId
   * @return scheduler
   */
  public synchronized Scheduler getScheduler(String agentId) {
    DateTime start = DateTime.now();
    while (schedulerFactory == null && start.plus(30000).isBeforeNow()) {
      try {
        this.wait();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
View Full Code Here

   
    if (type == null) {
      // unix epoch for the timezone.
      DateTime startOfTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, instant.getZone());
      long intervalStart = ((instant.getMillis() - startOfTime.getMillis()) / length) * length;
      return startOfTime.plus(intervalStart);
    } else {
      return type.getTimeIntervalStart(
        instant,
        length
      );
View Full Code Here

      duration = Duration.standardHours(1);
    }
   
    // check interval at next half hour
    DateTime firstTimeslot = getNextHalfHour();
    Interval test = new Interval(firstTimeslot, firstTimeslot.plus(duration));
    testInterval(infeasible, preferred, test, solutions);
   
    // loop over all infeasible intervals
    for (Interval i : infeasible) {
      // test timeslot left from the infeasible interval
View Full Code Here

      duration = Duration.standardHours(1);
    }
   
    // check interval at next half hour
    DateTime firstTimeslot = getNextHalfHour();
    Interval test = new Interval(firstTimeslot, firstTimeslot.plus(duration));
    testInterval(infeasible, preferred, test, solutions);
   
    // loop over all infeasible intervals
    for (Interval i : infeasible) {
      // test timeslot left from the infeasible interval
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.