Example usage for java.time OffsetDateTime isBefore

List of usage examples for java.time OffsetDateTime isBefore

Introduction

In this page you can find the example usage for java.time OffsetDateTime isBefore.

Prototype

public boolean isBefore(OffsetDateTime other) 

Source Link

Document

Checks if the instant of this date-time is before that of the specified date-time.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.MAX;

    System.out.println(o.isBefore(OffsetDateTime.MIN));
}

From source file:org.openmhealth.schema.domain.omh.TimeInterval.java

public static TimeInterval ofStartDateTimeAndEndDateTime(OffsetDateTime startDateTime,
        OffsetDateTime endDateTime) {

    checkNotNull(startDateTime, "A start date time hasn't been specified.");
    checkNotNull(endDateTime, "An end date time hasn't been specified.");
    checkArgument(!endDateTime.isBefore(startDateTime), "The specified start and end date times are reversed.");

    TimeInterval timeInterval = new TimeInterval();

    timeInterval.startDateTime = startDateTime;
    timeInterval.endDateTime = endDateTime;

    return timeInterval;
}

From source file:org.openmhealth.data.generator.service.TimestampedValueGroupGenerationServiceImpl.java

@Override
public Iterable<TimestampedValueGroup> generateValueGroups(MeasureGenerationRequest request) {

    ExponentialDistribution interPointDurationDistribution = new ExponentialDistribution(
            request.getMeanInterPointDuration().getSeconds());

    long totalDurationInS = Duration.between(request.getStartDateTime(), request.getEndDateTime()).getSeconds();

    OffsetDateTime effectiveDateTime = request.getStartDateTime();
    List<TimestampedValueGroup> timestampedValueGroups = new ArrayList<>();

    do {/*  w  w w .ja  v a2s .  c  om*/
        effectiveDateTime = effectiveDateTime.plus((long) interPointDurationDistribution.sample(), SECONDS);

        if (!effectiveDateTime.isBefore(request.getEndDateTime())) {
            break;
        }

        if (request.isSuppressNightTimeMeasures() != null && request.isSuppressNightTimeMeasures()
                && (effectiveDateTime.getHour() >= NIGHT_TIME_START_HOUR
                        || effectiveDateTime.getHour() < NIGHT_TIME_END_HOUR)) {
            continue;
        }

        TimestampedValueGroup valueGroup = new TimestampedValueGroup();
        valueGroup.setTimestamp(effectiveDateTime);

        double trendProgressFraction = (double) Duration.between(request.getStartDateTime(), effectiveDateTime)
                .getSeconds() / totalDurationInS;

        for (Map.Entry<String, BoundedRandomVariableTrend> trendEntry : request.getTrends().entrySet()) {

            String key = trendEntry.getKey();
            BoundedRandomVariableTrend trend = trendEntry.getValue();

            double value = trend.nextValue(trendProgressFraction);
            valueGroup.setValue(key, value);
        }

        timestampedValueGroups.add(valueGroup);
    } while (true);

    return timestampedValueGroups;
}