java.time.OffsetDateTime#isBefore ( )源码实例Demo

下面列出了java.time.OffsetDateTime#isBefore ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: blackduck-alert   文件: UpdateChecker.java
/**
 * The Date Alert has in the About will always be slightly before the Docker Hub date. So if the two are within 1 hour of each other, then we will consider them the same.
 */
private int compareDateStrings(String first, String second) {
    try {
        OffsetDateTime firstDate = parseDate(first, DOCKER_DATE_FORMAT);
        OffsetDateTime secondDate = parseDate(second, DOCKER_DATE_FORMAT);

        OffsetDateTime hourEarlier = firstDate.minusHours(1);
        OffsetDateTime hourLater = firstDate.plusHours(1);

        boolean secondIsWithinAnHourOfFirst = hourEarlier.isBefore(secondDate) && hourLater.isAfter(secondDate);

        if (secondIsWithinAnHourOfFirst) {
            return 0;
        }
        if (firstDate.isAfter(secondDate)) {
            return -1;
        } else if (firstDate.isBefore(secondDate)) {
            return 1;
        }
    } catch (ParseException e) {
        logger.debug("Could not parse the date strings with the format {}.", DOCKER_DATE_FORMAT);
        logger.debug(e.getMessage(), e);
    }
    return 0;
}
 
源代码2 项目: OEE-Designer   文件: SetupEditorController.java
@Override
protected void saveRecord() throws Exception {
	// time period
	setTimePeriod(setupEvent);

	// material
	if (setupEvent.getMaterial() == null) {
		throw new Exception(DesignerLocalizer.instance().getErrorString("material.not.specified"));
	}

	// job
	setupEvent.setJob(tfJob.getText());

	// close off last setup
	List<KeyedObject> records = new ArrayList<>();
	records.add(setupEvent);

	// close off last setup
	OeeEvent lastRecord = PersistenceService.instance().fetchLastEvent(setupEvent.getEquipment(),
			OeeEventType.MATL_CHANGE);

	if (lastRecord != null && !(lastRecord.getKey().equals(setupEvent.getKey()))) {
		OffsetDateTime newStart = setupEvent.getStartTime();
		OffsetDateTime lastStart = lastRecord.getStartTime();

		if (newStart.isBefore(lastStart)) {
			throw new Exception(
					DesignerLocalizer.instance().getErrorString("start.before.end", newStart, lastStart));
		}

		lastRecord.setEndTime(newStart);
		Duration duration = Duration.between(lastRecord.getStartTime(), lastRecord.getEndTime());
		lastRecord.setDuration(duration);

		records.add(lastRecord);
	}

	// save records
	PersistenceService.instance().save(records);
}
 
源代码3 项目: FROST-Server   文件: Utils.java
public static TimeInterval intervalFromTimes(OffsetDateTime timeStart, OffsetDateTime timeEnd) {
    if (timeStart == null) {
        timeStart = OffsetDateTime.of(LocalDateTime.MAX, UTC);
    }
    if (timeEnd == null) {
        timeEnd = OffsetDateTime.of(LocalDateTime.MIN, UTC);
    }
    if (timeEnd.isBefore(timeStart)) {
        return null;
    } else {
        return TimeInterval.create(timeStart.toInstant().toEpochMilli(), timeEnd.toInstant().toEpochMilli());
    }
}
 
源代码4 项目: edison-microservice   文件: JobStatusCalculator.java
/**
 * Calculates whether or not the last job execution is too old.
 *
 * @param jobInfo       job info of the last job execution
 * @param jobDefinition job definition, specifying the max age of jobs
 * @return boolean
 */
protected boolean jobTooOld(final JobInfo jobInfo, final JobDefinition jobDefinition) {
    final Optional<OffsetDateTime> stopped = jobInfo.getStopped();
    if (stopped.isPresent() && jobDefinition.maxAge().isPresent()) {
        final OffsetDateTime deadlineToRerun = stopped.get().plus(jobDefinition.maxAge().get());
        return deadlineToRerun.isBefore(now());
    }

    return false;
}
 
源代码5 项目: dragonwell8_jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码6 项目: TencentKona-8   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码7 项目: jdk8u60   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码8 项目: OEE-Designer   文件: TrendChartController.java
@FXML
public void onRefresh() {
	try {
		onResetTrending();

		OffsetDateTime odtStart = null;
		OffsetDateTime odtEnd = null;

		// start date and time
		LocalDate startDate = dpStartDate.getValue();

		if (startDate != null) {
			Duration startSeconds = null;
			if (tfStartTime.getText() != null && tfStartTime.getText().trim().length() > 0) {
				startSeconds = AppUtils.durationFromString(tfStartTime.getText().trim());
			} else {
				startSeconds = Duration.ZERO;
			}

			LocalTime startTime = LocalTime.ofSecondOfDay(startSeconds.getSeconds());
			LocalDateTime ldtStart = LocalDateTime.of(startDate, startTime);
			odtStart = DomainUtils.fromLocalDateTime(ldtStart);
		}

		// end date and time
		LocalDate endDate = dpEndDate.getValue();

		if (endDate != null) {
			Duration endSeconds = null;
			if (tfEndTime.getText() != null && tfEndTime.getText().trim().length() > 0) {
				endSeconds = AppUtils.durationFromString(tfEndTime.getText().trim());
			} else {
				endSeconds = Duration.ZERO;
			}

			LocalTime endTime = LocalTime.ofSecondOfDay(endSeconds.getSeconds());
			LocalDateTime ldtEnd = LocalDateTime.of(endDate, endTime);
			odtEnd = DomainUtils.fromLocalDateTime(ldtEnd);
		}

		if (odtStart != null && odtEnd != null && odtEnd.isBefore(odtStart)) {
			throw new Exception(DesignerLocalizer.instance().getErrorString("start.before.end", odtStart, odtEnd));
		}

		List<OeeEvent> events = PersistenceService.instance().fetchEvents(eventResolver.getEquipment(),
				eventResolver.getType(), odtStart, odtEnd);

		for (OeeEvent event : events) {
			// plot values
			Object plottedValue = null;

			switch (eventResolver.getType()) {
			case AVAILABILITY:
				plottedValue = event.getReason().getName();
				break;

			case CUSTOM:
				break;

			case JOB_CHANGE:
				plottedValue = event.getJob();
				break;

			case MATL_CHANGE:
				plottedValue = event.getMaterial().getName();
				break;

			case PROD_GOOD:
			case PROD_REJECT:
			case PROD_STARTUP:
				plottedValue = event.getAmount();
				break;

			default:
				break;
			}

			// add event to table
			event.setSourceId(eventResolver.getSourceId());
			event.setOutputValue(plottedValue);
			addEvent(event);

			// plot it
			plotData(event.getInputValue(), plottedValue);
		}

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
@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 {
        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;
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码11 项目: openjdk-jdk9   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码12 项目: jdk8u-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码13 项目: hottub   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码14 项目: openjdk-8-source   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码15 项目: openjdk-8   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码16 项目: hono   文件: PrometheusBasedResourceLimitChecks.java
/**
 * Calculates the effective resource limit for a tenant for the given period from the configured values.
 * <p>
 * In the <em>monthly</em> mode, if the effectiveSince date doesn't fall on the 
 * first day of the month then the effective resource limit for the tenant is 
 * calculated as below.
 * <pre>
 *             configured limit 
 *   ---------------------------------- x No. of days from effectiveSince till lastDay of the targetDateMonth.
 *    No. of days in the current month
 * </pre>
 * <p>
 * For rest of the months and the <em>days</em> mode, the configured limit is used directly.
 *
 * @param effectiveSince The point of time on which the given resource limit came into effect.
 * @param targetDateTime The target date and time.
 * @param mode The mode of the period. 
 * @param configuredLimit The configured limit. 
 * @return The effective resource limit that has been calculated.
 */
long calculateEffectiveLimit(
        final OffsetDateTime effectiveSince,
        final OffsetDateTime targetDateTime,
        final PeriodMode mode,
        final long configuredLimit) {
    if (PeriodMode.MONTHLY.equals(mode)
            && configuredLimit > 0
            && !targetDateTime.isBefore(effectiveSince)
            && YearMonth.from(targetDateTime).equals(YearMonth.from(effectiveSince))
            && effectiveSince.getDayOfMonth() != 1) {
        final OffsetDateTime lastDayOfMonth = effectiveSince.with(TemporalAdjusters.lastDayOfMonth());
        final long daysBetween = ChronoUnit.DAYS
                .between(effectiveSince, lastDayOfMonth) + 1;
        return Double.valueOf(Math.ceil(daysBetween * configuredLimit / lastDayOfMonth.getDayOfMonth()))
                .longValue();
    }
    return configuredLimit;
}
 
源代码17 项目: jdk8u_jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码18 项目: jdk8u-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码19 项目: jdk8u-dev-jdk   文件: TCKOffsetDateTime.java
@Test(expectedExceptions=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}
 
源代码20 项目: j2objc   文件: TCKOffsetDateTime.java
@Test(expected=NullPointerException.class)
public void test_isBefore_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isBefore(null);
}