本文整理了Java中java.time.LocalDateTime.isEqual()
方法的一些代码示例,展示了LocalDateTime.isEqual()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.isEqual()
方法的具体详情如下:
包路径:java.time.LocalDateTime
类名称:LocalDateTime
方法名:isEqual
[英]Checks if this date-time is equal to the specified date-time.
This checks to see if this date-time represents the same point on the local time-line as the other date-time.
LocalDate a = LocalDateTime.of(2012, 6, 30, 12, 00);
LocalDate b = LocalDateTime.of(2012, 7, 1, 12, 00);
a.isEqual(b) == false
a.isEqual(a) == true
b.isEqual(a) == false
This method only considers the position of the two date-times on the local time-line. It does not take into account the chronology, or calendar system. This is different from the comparison in #compareTo(ChronoLocalDateTime), but is the same approach as #DATE_TIME_COMPARATOR.
[中]检查此日期时间是否等于指定的日期时间。
这将检查此日期时间是否表示本地时间线上与其他日期时间相同的点。
LocalDate a = LocalDateTime.of(2012, 6, 30, 12, 00);
LocalDate b = LocalDateTime.of(2012, 7, 1, 12, 00);
a.isEqual(b) == false
a.isEqual(a) == true
b.isEqual(a) == false
此方法仅考虑两个日期时间在本地时间线上的位置。它不考虑年表或日历系统。这与#compareTo(ChronoLocalDateTime)中的比较不同,但与#DATE_TIME_COMPARATOR的方法相同。
代码示例来源:origin: oblac/jodd
@Test
void testDecimalFloating() {
LocalDateTime ldt = LocalDateTime.of(1970, 1, 13, 14, 24, 0, 0);
JulianDate jdt = new JulianDate(2440600, 0.1);
assertTrue(ldt.isEqual(jdt.toLocalDateTime()));
JulianDate jdt2 = new JulianDate(2440600, 0.09999999991);
assertTrue(ldt.isEqual(jdt2.toLocalDateTime()));
JulianDate jdt3 = new JulianDate(2440600, 0.10000001);
assertTrue(ldt.isEqual(jdt3.toLocalDateTime()));
}
}
代码示例来源:origin: com.rbmhtechnology.vind/solr-suggestion-handler
public boolean equals(Object o) {
try {
return ((Interval)o).start.isEqual(this.start) && ((Interval)o).end.isEqual(this.end);
} catch (Exception e) {
return false;
}
}
}
代码示例来源:origin: st-tu-dresden/salespoint
/**
* Returns whether the given {@link LocalDateTime} is contained in the current {@link Interval}.
*
* @param reference must not be {@literal null}.
* @return
*/
public boolean contains(LocalDateTime reference) {
Assert.notNull(reference, "Reference must not be null!");
boolean afterOrOnStart = start.isBefore(reference) || start.isEqual(reference);
boolean beforeOrOnEnd = end.isAfter(reference) || end.isEqual(reference);
return afterOrOnStart && beforeOrOnEnd;
}
代码示例来源:origin: st-tu-dresden/salespoint
/**
* Creates a new {@link Interval} between the given start and end.
*
* @param start must not be {@literal null}.
* @param end must not be {@literal null}.
*/
private Interval(LocalDateTime start, LocalDateTime end) {
Assert.notNull(start, "Start must not be null!");
Assert.notNull(end, "End must not be null!");
Assert.isTrue(start.isBefore(end) || start.isEqual(end), "Start must be before or equal to end!");
this.start = start;
this.end = end;
}
代码示例来源:origin: org.apereo.cas/cas-server-support-trusted-mfa
@Override
public Set<? extends MultifactorAuthenticationTrustRecord> get(final LocalDateTime onOrAfterDate) {
expire(onOrAfterDate);
return storage
.values()
.stream()
.filter(entry -> entry.getRecordDate().isEqual(onOrAfterDate) || entry.getRecordDate().isAfter(onOrAfterDate))
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
}
代码示例来源:origin: eXparity/hamcrest-date
@Override
public boolean isSame(final LocalDateTime other) {
return wrapped.get().truncatedTo(accuracy).isEqual(other.truncatedTo(accuracy));
}
代码示例来源:origin: org.apereo.cas/cas-server-support-trusted-mfa
@Override
public Set<? extends MultifactorAuthenticationTrustRecord> get(final LocalDateTime onOrAfterDate) {
expire(onOrAfterDate);
return storage.asMap()
.values()
.stream()
.filter(entry -> entry.getRecordDate().isEqual(onOrAfterDate) || entry.getRecordDate().isAfter(onOrAfterDate))
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
}
代码示例来源:origin: org.apereo.cas/cas-server-support-trusted-mfa
@Override
public void expire(final LocalDateTime onOrBefore) {
val results = storage
.values()
.stream()
.filter(entry -> entry.getRecordDate().isEqual(onOrBefore) || entry.getRecordDate().isBefore(onOrBefore))
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
LOGGER.info("Found [{}] expired records", results.size());
if (!results.isEmpty()) {
results.forEach(entry -> storage.remove(entry.getRecordKey()));
LOGGER.info("Invalidated and removed [{}] expired records", results.size());
writeTrustedRecordsToResource();
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-trusted-mfa
@Override
public void expire(final LocalDateTime onOrBefore) {
val results = storage.asMap()
.values()
.stream()
.filter(entry -> entry.getRecordDate().isEqual(onOrBefore) || entry.getRecordDate().isBefore(onOrBefore))
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
LOGGER.info("Found [{}] expired records", results.size());
if (!results.isEmpty()) {
results.forEach(entry -> storage.invalidate(entry.getRecordKey()));
LOGGER.info("Invalidated and removed [{}] expired records", results.size());
}
}
代码示例来源:origin: dev.rico/rico-client
final ScheduledTask nextTask = tasks.get(0);
final LocalDateTime now = LocalDateTime.now();
if(nextTask.getScheduledStartDate().isBefore(now) || nextTask.getScheduledStartDate().isEqual(now)) {
tasks.remove(nextTask);
schedule(nextTask);
代码示例来源:origin: stackoverflow.com
LocalDateTime estimatedEndTime = jobStartAt.plusHours(task.getDurationInHours());
if (estimatedEndTime.isAfter(closingAt) || estimatedEndTime.isEqual(closingAt)) {
LocalDateTime fallOverStartAt = jobStartAt;
do {
Duration duration = Duration.between(closingAt, estimatedEndTime);
estimatedEndTime = LocalDateTime.of(fallOverStartAt.toLocalDate(), closingTime);
fallOverStartAt = fallOverStartAt.plusDays(1);
fallOverStartAt = LocalDateTime.of(fallOverStartAt.toLocalDate(), openingTime);
estimatedEndTime = fallOverStartAt.plusHours(duration.toHours());
closingAt = closingAt.plusDays(1);
} while (estimatedEndTime.isAfter(closingAt));
// Job will start on/at jobStartAt
// and will end on/at estimatedEndTime
} else {
// Job will start on/at jobStartAt
// and will end on/at estimatedEndTime
}
// The next job starts here
jobStartAt = estimatedEndTime;
代码示例来源:origin: stackoverflow.com
return (value.isAfter(from) || value.isEqual(from)) &&
(value.isBefore(to) || value.isEqual(to));
代码示例来源:origin: stackoverflow.com
@Test
public void testDate() {
MyObject object = new MyObject();
// Get the current date time
LocalDateTime time = LocalDateTime.now();
// Affect the current date time to the field date
object.myMethod();
// Make sure that it is before or equals
Assert.assertTrue(time.isBefore(object.getDate()) || time.isEqual(object.getDate()));
}
代码示例来源:origin: ogcs/Okra
public static LinkedList<Long> getTimeList(long time0, long time1, String zone) {
ZoneOffset offset = ZoneOffset.of(zone);
LocalDateTime var0 = LocalDateTime.ofEpochSecond(time0 / 1000L, 0, offset)
.withHour(0).withMinute(0).withSecond(0);
LocalDateTime var1 = LocalDateTime.ofEpochSecond(time1 / 1000L, 0, offset)
.withHour(0).withMinute(0).withSecond(0);
LinkedList<Long> dayList = new LinkedList<>();
if (var1.isBefore(var0)) {
return dayList;
}
LocalDateTime tmp = var0;
while (tmp.isBefore(var1) || tmp.isEqual(var1)) {
dayList.add(tmp.toLocalDate().atStartOfDay().toEpochSecond(offset) * 1000L);
tmp = tmp.plusDays(1);
}
return dayList;
}
代码示例来源:origin: ogcs/Okra
public static LinkedList<String> getDayList(long time0, long time1, String zone) {
ZoneOffset offset = ZoneOffset.of(zone);
LocalDateTime var0 = LocalDateTime.ofEpochSecond(time0 / 1000L, 0, offset)
.withHour(0).withMinute(0).withSecond(0);
LocalDateTime var1 = LocalDateTime.ofEpochSecond(time1 / 1000L, 0, offset)
.withHour(0).withMinute(0).withSecond(0);
LinkedList<String> dayList = new LinkedList<>();
if (var1.isBefore(var0)) {
return dayList;
}
LocalDateTime tmp = var0;
while (tmp.isBefore(var1) || tmp.isEqual(var1)) {
dayList.add(date(tmp.toLocalDate()));
tmp = tmp.plusDays(1);
}
return dayList;
}
代码示例来源:origin: amedia/freemarker-java-8
@SuppressWarnings("Duplicates")
@Override
public Object exec(List list) throws TemplateModelException {
LocalDateTimeAdapter adapter = (LocalDateTimeAdapter) list.get(0);
switch(method) {
case METHOD_EQUALS:
return getObject().isEqual(adapter.getObject());
case METHOD_AFTER:
return getObject().isAfter(adapter.getObject());
case METHOD_BEFORE:
return getObject().isBefore(adapter.getObject());
}
throw new TemplateModelException("method not implemented");
}
}
代码示例来源:origin: org.codehaus.httpcache4j/httpcache4j-api
return false;
if (OptionalUtils.exists(expires, e -> e.isBefore(date.get())) || OptionalUtils.exists(expires, e -> e.isEqual(date.get()))) {
return false;
内容来源于网络,如有侵权,请联系作者删除!