Package org.joda.time

Examples of org.joda.time.Interval


      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
      test = new Interval(i.getStart().minus(duration), i.getStart());
      testInterval(infeasible, preferred, test, solutions);
     
      // test timeslot right from the infeasible interval
      test = new Interval(i.getEnd(), i.getEnd().plus(duration));
      testInterval(infeasible, preferred, test, solutions);
    }

    // loop over all preferred intervals
    for (Weight w : preferred) {
      // test timeslot left from the start of the preferred interval
      test = new Interval(w.getStart().minus(duration), w.getStart());
      testInterval(infeasible, preferred, test, solutions);

      // test timeslot right from the start of the preferred interval
      test = new Interval(w.getStart(), w.getStart().plus(duration));
      testInterval(infeasible, preferred, test, solutions);
     
      // test timeslot left from the end of the preferred interval
      test = new Interval(w.getEnd().minus(duration), w.getEnd());
      testInterval(infeasible, preferred, test, solutions);
     
      // test timeslot right from the end of the preferred interval
      test = new Interval(w.getEnd(), w.getEnd().plus(duration));
      testInterval(infeasible, preferred, test, solutions);
    }
   
    // order the calculated feasible timeslots by weight, from highest to
    // lowest. In case of equals weights, the timeslots are ordered by
View Full Code Here


    if (activity != null) {
      String updated = activity.withStatus().getUpdated();
      if (updated != null) {
        DateTime dateUpdated = new DateTime(updated);
        DateTime now = DateTime.now();
        interval = new Interval(dateUpdated, now).toDurationMillis();
      }
    }
    if (interval < TEN_SECONDS) {
      interval = TEN_SECONDS;
    }
View Full Code Here

    }
    activity.withStatus().setEnd(end);

    // duration
    if (start != null && end != null) {
      Interval interval = new Interval(new DateTime(start), new DateTime(
          end));
      Long duration = interval.toDurationMillis();
      activity.withConstraints().withTime().setDuration(duration);
    }

    // location
    String location = null;
View Full Code Here

  private double calculatePreference(
      List<Weight> preferredIntervals, Interval test) {
    double preference = 0;

    for (Weight interval : preferredIntervals) {
      Interval overlap = test.overlap(interval.getInterval());
      if (overlap != null) {
        Double weight = interval.getWeight();
        if (weight != null) {
          double durationCheck = test.toDurationMillis();
          double durationOverlap = overlap.toDurationMillis();
          double avgWeight = (durationOverlap / durationCheck) * weight;
          preference += avgWeight;
        }
      }

View Full Code Here

      for (int i = 0; i < array.size(); i++) {
        ObjectNode obj = (ObjectNode) array.get(i);
        String start = obj.has("start") ? obj.get("start").asText()
            : null;
        String end = obj.has("end") ? obj.get("end").asText() : null;
        busy.add(new Interval(new DateTime(start), new DateTime(end)));
      }

      // store the interval in the state
      putAgentBusy(agent, busy);
View Full Code Here

        ISOChronology.getInstance());

    LocalDate firstTargetDate = new LocalDate(firstGregorianDate.toDateTimeAtStartOfDay().getMillis(), targetChrono);
    LocalDate lastTargetDate = new LocalDate(lastGregorianDate.toDateTimeAtStartOfDay().getMillis(), targetChrono);

    Interval interv = new Interval(firstTargetDate.toDateTimeAtStartOfDay(), lastTargetDate.plusDays(1)
        .toDateTimeAtStartOfDay());

    int targetYear = firstTargetDate.getYear();

    for (; targetYear <= lastTargetDate.getYear();) {
      LocalDate d = new LocalDate(targetYear, targetMonth, targetDay, targetChrono);
      if (interv.contains(d.toDateTimeAtStartOfDay())) {
        holidays.add(convertToISODate(d));
      }
      targetYear++;
    }
    return holidays;
View Full Code Here

//      }
    }
  }

  public static String elapsedTime(Date d1, Date d2){
    Interval interval = new Interval(d1.getTime(), d2.getTime());
    Period period = interval.toPeriod();
    return period.getDays() + " days, " + period.getHours()+" hours, " + period.getMinutes()  +" minutes, " +period.getSeconds()+" seconds";
  }
View Full Code Here

    if (interval == null) {
      return true;
    }

    Interval requestInterval = (Interval) line.getValue(LogConstants.INTERVAL);

    if (requestInterval == null) {
      return false;
    }

    return requestInterval.overlaps(interval) || requestInterval.abuts(interval);
  }
View Full Code Here

      return null;
    }

    DateTime t = (DateTime) line.getValue(LogConstants.DATE);

    return new Interval(from.toDateTime(t), to.toDateTime(t));
  }
View Full Code Here

    final UniformGranularitySpec granularitySpec = (UniformGranularitySpec) schema.getDataSchema().getGranularitySpec();

    Assert.assertEquals(
        "getIntervals",
        Lists.newArrayList(new Interval("2012-01-01/P1D")),
        granularitySpec.getIntervals().get()
    );

    Assert.assertEquals(
        "getSegmentGranularity",
View Full Code Here

TOP

Related Classes of org.joda.time.Interval

Copyright © 2018 www.massapicom. 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.