Example usage for org.joda.time Duration ZERO

List of usage examples for org.joda.time Duration ZERO

Introduction

In this page you can find the example usage for org.joda.time Duration ZERO.

Prototype

Duration ZERO

To view the source code for org.joda.time Duration ZERO.

Click Source Link

Document

Constant representing zero millisecond duration

Usage

From source file:net.cpollet.jixture.fixtures.generator.field.DateSequence.java

License:Apache License

/**
 * Build a sequence that will return values between {@code start} and {@code end} (inclusive) with an increment of
 * {@code increment}. For instance, in://from  w  w w  .j  av  a  2  s  .com
 * <pre>
 *     s1 = new DateSequence(
 *        new DateTime(1, 1, 1, 0, 0, 0),
 *        new DateTime(1, 1, 3, 0, 0, 0),
 *        new Period.days(1)
 *     );
 *     s1 = new DateSequence(
 *        new DateTime(1, 1, 1, 0, 0, 0),
 *        new DateTime(1, 1, 5, 0, 0, 0),
 *        new Period.days(1)
 *     );
 * </pre>
 * {@code s1} will generate the following dates: {@code 1-1-1T0:0:0}, {@code 1-1-2T0:0:0}, {@code 1-1-3T0:0:0} and
 * {@code s2} will generate {@code 1-1-1T0:0:0}, {@code 1-1-3T0:0:0}, {@code 1-1-5T0:0:0}.
 *
 * @param start first value in sequence, inclusive.
 * @param stop last element in sequence, inclusive.
 * @param period increment.
 *
 * @throws java.lang.IllegalArgumentException if start is less than stop or if increment is less than or equal to
 * 0ms.
 */
public DateSequence(DateTime start, DateTime stop, ReadablePeriod period) {
    AssertionUtils.assertTrue(period.toPeriod().toStandardDuration().isLongerThan(Duration.ZERO),
            "period must be > 0ms");
    AssertionUtils.assertTrue(!stop.isBefore(start), "stop must be >= start");

    this.start = start;
    this.stop = stop;
    this.period = period;

    reset();
}

From source file:net.oauth.jsontoken.FakeClock.java

License:Apache License

public FakeClock() {
    super(Duration.ZERO);
}

From source file:net.solarnetwork.central.dras.mock.biz.MockDRASObserverBiz.java

License:Open Source License

public MockDRASObserverBiz() {
    TimeZone tz = TimeZone.getTimeZone("Pacific/Auckland");

    uniLocation = new SolarLocation();
    uniLocation.setId(counter.decrementAndGet());
    uniLocation.setCountry("NZ");
    uniLocation.setCreated(new DateTime());
    uniLocation.setName("Mock Location");
    uniLocation.setRegion("UNI");
    uniLocation.setTimeZoneId(tz.getID());
    uniLocation.setLatitude(groupLatitude);
    uniLocation.setLongitude(groupLongitude);

    uniLocations = new LinkedHashMap<Long, SolarLocation>();
    uniLocations.put(uniLocation.getId(), uniLocation);

    uniGroups = new ArrayList<SolarNodeGroup>(numGroups);
    addGroup(new SolarNodeGroup(counter.decrementAndGet(), uniLocation.getId(), "Mock Group A"));
    addGroup(new SolarNodeGroup(counter.decrementAndGet(), uniLocation.getId(), "Mock Group B"));
    participantGroups = new ArrayList<CapabilityInformation>(numGroups);
    for (SolarNodeGroup group : uniGroups) {
        SimpleCapabilityInformation groupInfo = new SimpleCapabilityInformation();
        groupInfo.setId(group.getId());//from w  w  w .  ja v  a2  s  .  c  o m
        groupInfo.setLocation(uniLocation);
        groupInfo.setGenerationCapacityWatts(participantGenerationCapacity);
        groupInfo.setStorageCapacityWattHours(participantStorageCapacity);
        participantGroups.add(groupInfo);
    }

    uniProgramParticipants = new LinkedHashSet<Identity<Long>>(numNodes);
    participantGroupMemebers = new LinkedHashMap<Long, Set<CapabilityInformation>>(numGroups);
    for (int i = 0; i < numNodes; i++) {
        SolarNode participant = new SolarNode(counter.decrementAndGet(), createRandomLocation().getId());
        uniProgramParticipants.add(participant);
        int groupIndex = (i % numGroups);
        SimpleCapabilityInformation group = (SimpleCapabilityInformation) participantGroups.get(groupIndex);
        Set<CapabilityInformation> groupMembers = participantGroupMemebers.get(group.getId());
        if (groupMembers == null) {
            groupMembers = new LinkedHashSet<CapabilityInformation>(numNodes);
            participantGroupMemebers.put(group.getId(), groupMembers);
        }
        SimpleCapabilityInformation info = new SimpleCapabilityInformation();
        info.setId(participant.getId());
        info.setLocation(uniLocations.get(participant.getLocationId()));
        info.setGenerationCapacityWatts(participantGenerationCapacity);
        info.setStorageCapacityWattHours(participantStorageCapacity);
        groupMembers.add(info);
        group.addGenerationCapacityWatts(participantGenerationCapacity);
        group.addStorageCapacityWattHours(participantStorageCapacity);
    }
    uniProgram = new Program(counter.decrementAndGet(), "UNI Program", 1);

    MutableDateTime mdt = new MutableDateTime(2011, 1, 1, 8, 0, 0, 0, DateTimeZone.forTimeZone(tz));
    uniEvents = new ArrayList<Event>(numEvents);
    uniEventParticipants = new LinkedHashMap<Long, EventParticipants>(numEvents);
    uniEventTargets = new LinkedHashMap<Long, EventTargets>(numEvents);

    EventRule eventRule = new EventRule(counter.decrementAndGet(), EventRule.RuleKind.LOAD_AMOUNT,
            EventRule.ScheduleKind.DYNAMIC);
    addEventRule(eventRule);

    for (int i = 0; i < numEvents; i++) {
        Event event = new Event(counter.decrementAndGet(), uniProgram.getId(),
                String.format("Mock Event %d", (i + 1)), mdt.toDateTime(),
                mdt.toDateTime().plus(Period.hours(2)));

        Set<Identity<Long>> groupSet = new LinkedHashSet<Identity<Long>>(2);
        switch (i % 3) {
        case 0:
            groupSet.add(participantGroups.get(0));
            break;

        case 1:
            groupSet.add(participantGroups.get(1));
            break;

        case 2:
            groupSet.add(participantGroups.get(0));
            groupSet.add(participantGroups.get(1));
            break;
        }
        EventParticipants ep = new EventParticipants(counter.decrementAndGet(), event.getId(), null, groupSet);
        uniEventParticipants.put(event.getId(), ep);

        // give each event a load shed target of 1kW
        EventTargets et = new EventTargets(counter.decrementAndGet(), eventRule.getId(),
                new TreeSet<EventTarget>(Arrays.asList(new EventTarget(Duration.ZERO, 1000D))));

        addEvent(event, ep, et);
        mdt.addWeeks(1);
    }
}

From source file:net.solarnetwork.central.dras.mock.biz.MockDRASOperatorBiz.java

License:Open Source License

@Override
public Event createEvent(Program program, String name, ReadableDateTime eventDate, ReadableDateTime endDate) {
    Event e = new Event(mockObserverBiz.counter.decrementAndGet(), program.getId(),
            (name != null ? name/*from  w w w  . java2s .  c om*/
                    : String.format("Mock Event %d",
                            (mockObserverBiz.getEvents(program, null, null).size() + 1))),
            eventDate.toDateTime(), endDate.toDateTime());

    EventParticipants ep = new EventParticipants(mockObserverBiz.counter.decrementAndGet(), e.getId(), null,
            null);

    EventRule rule = new EventRule(mockObserverBiz.counter.decrementAndGet(), RuleKind.LOAD_AMOUNT,
            ScheduleKind.DYNAMIC);
    mockObserverBiz.addEventRule(rule);

    EventTargets et = new EventTargets(mockObserverBiz.counter.decrementAndGet(), rule.getId(),
            new TreeSet<EventTarget>(Arrays.asList(new EventTarget(Duration.ZERO, 1000D))));
    mockObserverBiz.addEvent(e, ep, et);
    return e;
}

From source file:net.sourceforge.fenixedu.domain.ExecutionCourse.java

License:Open Source License

public Duration getTotalShiftsDuration() {
    Duration totalDuration = Duration.ZERO;
    for (Shift shift : getAssociatedShifts()) {
        totalDuration = totalDuration.plus(shift.getTotalDuration());
    }/*  ww  w .j  av  a  2  s.  co m*/
    return totalDuration;
}

From source file:net.sourceforge.fenixedu.domain.Shift.java

License:Open Source License

public Duration getTotalDuration() {
    Duration duration = Duration.ZERO;
    Collection<Lesson> lessons = getAssociatedLessonsSet();
    for (Lesson lesson : lessons) {
        duration = duration.plus(lesson.getTotalDuration());
    }/*from   w w  w .  j  a va2 s.co  m*/
    return duration;
}

From source file:net.sourceforge.fenixedu.domain.Teacher.java

License:Open Source License

public Duration getLecturedDurationOnExecutionCourse(ExecutionCourse executionCourse) {
    Duration duration = Duration.ZERO;
    Professorship professorship = getProfessorshipByExecutionCourse(executionCourse);
    TeacherService teacherService = getTeacherServiceByExecutionPeriod(executionCourse.getExecutionPeriod());
    if (teacherService != null) {
        List<DegreeTeachingService> teachingServices = teacherService
                .getDegreeTeachingServiceByProfessorship(professorship);
        for (DegreeTeachingService teachingService : teachingServices) {
            duration = duration.plus(new Duration(new Double((teachingService.getPercentage() / 100)
                    * teachingService.getShift().getCourseLoadWeeklyAverage().doubleValue() * 3600 * 1000)
                            .longValue()));
        }/*from  w ww  .j  ava  2  s .  c  o m*/
    }
    return duration;
}

From source file:org.apache.beam.learning.katas.triggers.earlytriggers.Task.java

License:Apache License

static PCollection<Long> applyTransform(PCollection<String> events) {
    return events
            .apply(Window.<String>into(FixedWindows.of(Duration.standardDays(1)))
                    .triggering(AfterWatermark.pastEndOfWindow()
                            .withEarlyFirings(AfterProcessingTime.pastFirstElementInPane()))
                    .withAllowedLateness(Duration.ZERO).discardingFiredPanes())

            .apply(Combine.globally(Count.<String>combineFn()).withoutDefaults());
}

From source file:org.apache.beam.learning.katas.triggers.eventtimetriggers.Task.java

License:Apache License

static PCollection<Long> applyTransform(PCollection<String> events) {
    return events
            .apply(Window.<String>into(FixedWindows.of(Duration.standardSeconds(5)))
                    .triggering(AfterWatermark.pastEndOfWindow()).withAllowedLateness(Duration.ZERO)
                    .discardingFiredPanes())

            .apply(Combine.globally(Count.<String>combineFn()).withoutDefaults());
}

From source file:org.apache.beam.learning.katas.triggers.windowaccummode.Task.java

License:Apache License

static PCollection<Long> applyTransform(PCollection<String> events) {
    return events
            .apply(Window.<String>into(FixedWindows.of(Duration.standardDays(1)))
                    .triggering(AfterWatermark.pastEndOfWindow()
                            .withEarlyFirings(AfterProcessingTime.pastFirstElementInPane()))
                    .withAllowedLateness(Duration.ZERO).accumulatingFiredPanes())

            .apply(Combine.globally(Count.<String>combineFn()).withoutDefaults());
}