本文整理汇总了Java中java.time.LocalDateTime.isBefore方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.isBefore方法的具体用法?Java LocalDateTime.isBefore怎么用?Java LocalDateTime.isBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.isBefore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRangeOfLocalDateTimes
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test(dataProvider = "LocalDateTimeRanges")
public void testRangeOfLocalDateTimes(LocalDateTime start, LocalDateTime end, Duration step, boolean parallel) {
final boolean ascend = start.isBefore(end);
final Range<LocalDateTime> range = Range.of(start, end, step, v -> v.getHour() == 6);
final Array<LocalDateTime> array = range.toArray(parallel);
final LocalDateTime first = array.first(v -> true).map(ArrayValue::getValue).get();
final LocalDateTime last = array.last(v -> true).map(ArrayValue::getValue).get();
Assert.assertEquals(array.typeCode(), ArrayType.LOCAL_DATETIME);
Assert.assertTrue(!array.style().isSparse());
Assert.assertEquals(range.start(), start, "The range start");
Assert.assertEquals(range.end(), end, "The range end");
int index = 0;
LocalDateTime value = first;
while (ascend ? value.isBefore(last) : value.isAfter(last)) {
final LocalDateTime actual = array.getValue(index);
Assert.assertEquals(actual, value, "Value matches at " + index);
Assert.assertTrue(ascend ? actual.compareTo(start) >= 0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + index);
value = ascend ? value.plus(step) : value.minus(step);
while (value.getHour() == 6) value = ascend ? value.plus(step) : value.minus(step);
index++;
}
}
示例2: checkDone
import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean checkDone(){
LocalDateTime currentDateTime = LocalDateTime.now();
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
// String nowDate = currentDateTime.format(formatter);
String[] datarrayString = date.split("-");
String[] timeendarray = getTimeClose().split(":");
LocalDateTime pickedTimeEnd = LocalDateTime.of(Integer.parseInt(datarrayString[0]), Integer.parseInt(datarrayString[1]), Integer.parseInt(datarrayString[2]), Integer.parseInt(timeendarray[0]), Integer.parseInt(timeendarray[1]), Integer.parseInt(timeendarray[2]));
if (pickedTimeEnd.isBefore(currentDateTime)){
return true;
}
else{
return false;
}
}
示例3: checkDateTime
import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean checkDateTime(){ /// not working...?
LocalDateTime currentDateTime = LocalDateTime.now();
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
// String nowDate = currentDateTime.format(formatter);
String[] datarrayString = date.split("-");
String[] timeendarray = "23:59:59".split(":");
LocalDateTime pickedTimeEnd = LocalDateTime.of(Integer.parseInt(datarrayString[0]),Integer.parseInt(datarrayString[1]),Integer.parseInt(datarrayString[2]), Integer.parseInt(timeendarray[0]), Integer.parseInt(timeendarray[1]), Integer.parseInt(timeendarray[2]));
if(pickedTimeEnd.isBefore(currentDateTime)){
return false;
}
//else if(pickedTimeEnd.isBefore(currentDateTime)){
// return false;
//}
else{
System.out.print(pickedTimeEnd +" "+currentDateTime);
return true;
}
}
示例4: findOffsetInfo
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Finds the offset info for a local date-time and transition.
*
* @param dt the date-time, not null
* @param trans the transition, not null
* @return the offset info, not null
*/
private Object findOffsetInfo(LocalDateTime dt, ZoneOffsetTransition trans) {
LocalDateTime localTransition = trans.getDateTimeBefore();
if (trans.isGap()) {
if (dt.isBefore(localTransition)) {
return trans.getOffsetBefore();
}
if (dt.isBefore(trans.getDateTimeAfter())) {
return trans;
} else {
return trans.getOffsetAfter();
}
} else {
if (dt.isBefore(localTransition) == false) {
return trans.getOffsetAfter();
}
if (dt.isBefore(trans.getDateTimeAfter())) {
return trans.getOffsetBefore();
} else {
return trans;
}
}
}
示例5: mutate
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Creates a new ChronoFrequency which has progressed in the ChronoSeries by one step.
*
* @param chronoSeries time series data to traverse
* @return new ChronoFrequency with latest frequency from traversing time series data
*/
@NotNull
@Override
public ChronoFrequency mutate(@NotNull ChronoSeries chronoSeries) {
if (seriesPosition >= requireNonNull(chronoSeries).getSize()) {
//start from beginning of series
return new ChronoFrequency(chronoUnit, 0, getMinimumFrequency(), getMaximumFrequency(),
chronoSeries.getTimestamp(0));
}
Instant nextTimestamp = chronoSeries.getTimestamp(seriesPosition);
LocalDateTime firstDateTime = getLastOccurrenceTimestamp().atZone(ZoneOffset.UTC).toLocalDateTime();
LocalDateTime secondDateTime = nextTimestamp.atZone(ZoneOffset.UTC).toLocalDateTime();
if (secondDateTime.isBefore(firstDateTime)) {
throw new RuntimeException("first: " + firstDateTime + "; second: " + secondDateTime);
}
//update chrono frequency gene
long frequency = getChronoUnit().between(firstDateTime, secondDateTime);
LocalDateTime addedDateTime = firstDateTime.plus(frequency, getChronoUnit());
if (addedDateTime.isBefore(secondDateTime) && isWithinRange(frequency)) {
frequency++;
} else if (frequency == 0) {
//no point in a frequency of nothing
frequency++;
}
return mutateChronoFrequency(frequency, nextTimestamp);
}
示例6: calculateTimestampRanges
import java.time.LocalDateTime; //导入方法依赖的package包/类
private void calculateTimestampRanges() {
LocalDateTime endTime = chronoSeries.getEndLocalDateTime();
LocalDateTime itrTime = chronoSeries.getBeginLocalDateTime();
logger.debug("Starting range determine loop");
while (searchRange && (itrTime.isEqual(endTime) || itrTime.isBefore(endTime))) {
for (ChronoPattern chronoPattern : chronoPatternSeq) {
if (tempSkipUnit != null && chronoPattern != smallestPattern
&& chronoPattern.getChronoScaleUnit().getChronoUnit() == tempSkipUnit.getChronoUnit()) {
continue;
} else {
tempSkipUnit = null;
}
LocalDateTime startItrTime = itrTime;
logger.trace("Start itrTime: " + startItrTime);
itrTime = progressTime(endTime, itrTime, chronoPattern);
logger.trace("End itrTime: " + itrTime);
}
}
logger.debug("Finished range determine loop");
if (patternStartLocalDateTime != null && patternStartLocalDateTime.isBefore(chronoSeries.getBeginLocalDateTime())) {
patternStartLocalDateTime = chronoSeries.getBeginLocalDateTime();
}
if (patternEndLocalDateTime != null && patternEndLocalDateTime.isAfter(chronoSeries.getEndLocalDateTime())) {
patternEndLocalDateTime = chronoSeries.getEndLocalDateTime();
}
for (Instant[] instants : timestampRanges) {
rangeDuration = rangeDuration.plus(Duration.between(instants[0], instants[1]));
}
logger.debug("Range duration: " + rangeDuration);
}
示例7: assertSignupTimeNotBeforeRaidStart
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void assertSignupTimeNotBeforeRaidStart(User user, LocalDateTime dateAndTime,
LocalDateTime endOfRaid, LocaleService localeService,
boolean isExRaid) {
final LocalDateTime startOfRaid = getStartOfRaid(endOfRaid, isExRaid);
if (dateAndTime.isBefore(startOfRaid)) {
throw new UserMessedUpException(user,
localeService.getMessageFor(LocaleService.SIGN_BEFORE_RAID, localeService.getLocaleForUser(user),
printTimeIfSameDay(dateAndTime), printTimeIfSameDay(startOfRaid)));
}
}
示例8: assertTimeInRaidTimespan
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void assertTimeInRaidTimespan(User user, LocalDateTime dateTimeToCheck, Raid raid,
LocaleService localeService) {
final LocalDateTime startOfRaid = getStartOfRaid(raid.getEndOfRaid(), raid.isExRaid());
final boolean timeIsSameOrBeforeEnd =
raid.getEndOfRaid().isAfter(dateTimeToCheck) || raid.getEndOfRaid().equals(dateTimeToCheck);
final boolean timeIsSameOrAfterStart =
startOfRaid.isBefore(dateTimeToCheck) || startOfRaid.equals(dateTimeToCheck);
if (!(timeIsSameOrBeforeEnd && timeIsSameOrAfterStart)) {
throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.TIME_NOT_IN_RAID_TIMESPAN,
localeService.getLocaleForUser(user), printDateTime(dateTimeToCheck),
printDateTime(startOfRaid), printTimeIfSameDay(raid.getEndOfRaid())));
}
}
示例9: raidIsActiveAndRaidGroupNotExpired
import java.time.LocalDateTime; //导入方法依赖的package包/类
private static boolean raidIsActiveAndRaidGroupNotExpired(LocalDateTime endOfRaid,
LocalDateTime raidGroupStartTime,
ClockService clockService) {
final LocalDateTime currentDateTime = clockService.getCurrentDateTime();
return raidGroupStartTime != null &&
currentDateTime.isBefore(
raidGroupStartTime.plusMinutes(5))
// 20 seconds here to match the 15 second sleep for the edit task
&& currentDateTime.isBefore(endOfRaid.minusSeconds(20));
}
示例10: isSubjectOfNotification
import java.time.LocalDateTime; //导入方法依赖的package包/类
private boolean isSubjectOfNotification(GoogleEntry entry, LocalDateTime now) {
List<GoogleEntryReminder> reminders = Lists.newArrayList();
reminders.addAll(entry.getReminders());
if (reminders.isEmpty()) {
reminders.addAll(((GoogleCalendar) entry.getCalendar()).getDefaultReminders());
}
for (GoogleEntryReminder reminder : reminders) {
if (reminder.getMethod() != GoogleEntryReminder.RemindMethod.POPUP) {
continue;
}
if (reminder.getMinutes() == null || reminder.getMinutes() < 0) {
continue;
}
if (!now.isBefore(entry.getStartAsLocalDateTime())) {
continue;
}
long distanceMinutes = now.until(entry.getStartAsLocalDateTime(), ChronoUnit.MINUTES);
if (distanceMinutes == reminder.getMinutes()) {
return true;
}
}
return false;
}
示例11: generateLogRecords
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static LogfileSummary generateLogRecords(LogfileType type, LocalDateTime start, LocalDateTime end, Consumer<String> consumer) {
LogfileSummary summary = new LogfileSummary();
LocalDateTime next = start;
while (next.isBefore(end)) {
consumer.accept(createLogEntry(type, next, summary));
next = next.plusNanos(5000000L);
}
return summary;
}
示例12: schedule
import java.time.LocalDateTime; //导入方法依赖的package包/类
private void schedule() {
LocalDateTime now = LocalDateTime.now();
LocalDateTime next = renewalCheckTime.atDate(now.toLocalDate());
if (next.isBefore(now)) {
next = next.plusDays(1);
}
if (activeTimerId != null) {
vertx.cancelTimer(activeTimerId);
activeTimerId = null;
}
activeTimerId = vertx.setTimer(now.until(next, MILLIS), timerId -> {
logger.info("Renewal check starting");
activeTimerId = null;
Future<Void> checked;
try {
checked = check();
} catch (IllegalStateException e) {
// someone else already updating, skip
checked = failedFuture(e);
}
checked.setHandler(ar -> {
if (ar.succeeded()) {
logger.info("Renewal check completed successfully");
} else {
logger.warn("Renewal check failed", ar.cause());
}
});
});
logger.info("Scheduled next renewal check at " + next);
}
示例13: isActive
import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean isActive(ClockService clockService) {
final LocalDateTime currentDateTime = clockService.getCurrentDateTime();
return currentDateTime.isBefore(endOfRaid) &&
getStartOfRaid(endOfRaid, isExRaid()).isBefore(currentDateTime);
}
示例14: clamp
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static final LocalDateTime clamp(final LocalDateTime MIN, final LocalDateTime MAX, final LocalDateTime VALUE) {
if (VALUE.isBefore(MIN)) return MIN;
if (VALUE.isAfter(MAX)) return MAX;
return VALUE;
}
示例15: setPanel
import java.time.LocalDateTime; //导入方法依赖的package包/类
public void setPanel(){
jLabel4.setText(name);
jLabel14.setText(ClassID);
jLabel7.setText(date);
jButton4.setVisible(false);
///find existing quiz for day.
q= new Quiz(con,ClassID);
quizID = q.searchDate(date);
if(quizID == -1){
jPanel2.setVisible(false);
jLabel5.setText("There is no quiz set for this day. Click below to set one up.");
if(q.checkDateTime()){
jButton2.setVisible(true);
jLabel5.setText("There is no quiz set for this day. Click below to set one up.");
}
else{
jLabel5.setText("There is no quiz set for this day. Try looking for another day.");
jButton2.setVisible(false);
}
}
else{
jPanel2.setVisible(true);
jButton2.setVisible(false);
jTextField1.setText(q.getTimeOpen());
jTextField2.setText(q.getTimeClose());
//////checking date close open time
LocalDateTime currentDateTime = LocalDateTime.now();
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
// String nowDate = currentDateTime.format(formatter);
String[] datarrayString = date.split("-");
String[] timeendarray = q.getTimeOpen().split(":");
LocalDateTime pickedDate = LocalDateTime.of(Integer.parseInt(datarrayString[0]), Integer.parseInt(datarrayString[1]), Integer.parseInt(datarrayString[2]), Integer.parseInt(timeendarray[0]), Integer.parseInt(timeendarray[1]), Integer.parseInt(timeendarray[2]));
if(currentDateTime.isBefore(pickedDate)){
jButton3.setVisible(true);
jLabel5.setText(quizID+ "You can still edit this quiz");
jLabel13.setText("No");
}
else{
jLabel5.setText(quizID +" Not Editable. You may edit the table below\n, but it will not update to the database.");
jButton3.setVisible(false);
jLabel13.setText("Yes");
jButton4.setVisible(true);
}
}
}