本文整理了Java中java.time.OffsetDateTime.compareTo()
方法的一些代码示例,展示了OffsetDateTime.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.compareTo()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:compareTo
[英]Compares this OffsetDateTime to another date-time.
The comparison is based on the instant then on the local date-time. It is "consistent with equals", as defined by Comparable.
For example, the following is the comparator order:
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
public int compareTo(Role r)
{
if (this == r)
return 0;
if (!this.getGuild().equals(r.getGuild()))
throw new IllegalArgumentException("Cannot compare roles that aren't from the same guild!");
if (this.getPositionRaw() != r.getPositionRaw())
return this.getPositionRaw() - r.getPositionRaw();
OffsetDateTime thisTime = this.getCreationTime();
OffsetDateTime rTime = r.getCreationTime();
//We compare the provided role's time to this's time instead of the reverse as one would expect due to how
// discord deals with hierarchy. The more recent a role was created, the lower its hierarchy ranking when
// it shares the same position as another role.
return rTime.compareTo(thisTime);
}
代码示例来源:origin: pholser/junit-quickcheck
/**
* <p>Tells this generator to produce values within a specified
* {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
* maximum}, inclusive, with uniform distribution, down to the
* nanosecond.</p>
*
* <p>If an endpoint of the range is not specified, the generator will use
* dates with values of either {@link OffsetDateTime#MIN} or
* {@link OffsetDateTime#MAX} as appropriate.</p>
*
* <p>{@link InRange#format()} describes
* {@linkplain DateTimeFormatter#ofPattern(String) how the generator is to
* interpret the range's endpoints}.</p>
*
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(range.format());
if (!defaultValueOf(InRange.class, "min").equals(range.min()))
min = OffsetDateTime.parse(range.min(), formatter);
if (!defaultValueOf(InRange.class, "max").equals(range.max()))
max = OffsetDateTime.parse(range.max(), formatter);
if (min.compareTo(max) > 0)
throw new IllegalArgumentException(String.format("bad range, %s > %s", range.min(), range.max()));
}
代码示例来源:origin: com.sqlapp/sqlapp-core
@Override
public boolean hasNext() {
if (this.step>0){
return (next.compareTo(end)<0);
} else{
return (next.compareTo(end)>0);
}
}
代码示例来源:origin: org.jadira.usertype/usertype.core
@Override
public int compare(Object o1, Object o2) {
return ((OffsetDateTime) o1).compareTo((OffsetDateTime) o2);
}
}
代码示例来源:origin: org.jadira.usertype/usertype.extended
@Override
public int compare(Object o1, Object o2) {
return ((OffsetDateTime) o1).compareTo((OffsetDateTime) o2);
}
}
代码示例来源:origin: org.jadira.usertype/usertype.core
@Override
public int compare(Object o1, Object o2) {
return ((OffsetDateTime) o1).compareTo((OffsetDateTime) o2);
}
代码示例来源:origin: signaflo/java-timeseries
@Override
public int compareTo(@NonNull Time otherTime) {
return this.dateTime.compareTo(otherTime.dateTime);
}
代码示例来源:origin: MER-C/wiki-java
/**
* Compares this event to another one based on the recentness of their
* timestamps (more recent = positive return value), then
* alphabetically by user.
* @param other the event to compare to
* @return the comparator value, negative if less, positive if greater
*/
@Override
public int compareTo(Wiki.Event other)
{
int result = timestamp.compareTo(other.timestamp);
if (result == 0 && user != null)
result = user.compareTo(other.user);
return result;
}
}
代码示例来源:origin: com.sqlapp/sqlapp-core
@Override
public boolean hasNext() {
if (this.step.isPositive()){
return (next.compareTo(end)<0);
} else{
return (next.compareTo(end)>0);
}
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Is this period includes the specified temporal?
* @param dateTime either a date or a date time. Any other temporal type isn't supported.
* @return true if the specified date is included in this period, false otherwise.
*/
public boolean includes(final Temporal dateTime) {
OffsetDateTime dt = asOffsetDateTime(dateTime);
return dt.compareTo(startDateTime) >= 0 && dt.compareTo(endDateTime) <= 0;
}
代码示例来源:origin: org.n52.wps/engine
private Predicate<Path> shouldBeDeleted(OffsetDateTime threshold) {
return path -> Files.isDirectory(path) && getLastModifiedTime(path).filter(dt -> dt.compareTo(
threshold) <= 0).isPresent();
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Is this period ends before the specified temporal?
* @param dateTime either a date or a date time. Any other temporal type isn't supported.
* @return true if this period's end date is at or before the specified temporal (the period's
* end date is exclusive).
*/
public boolean endsBefore(final Temporal dateTime) {
OffsetDateTime dt = asOffsetDateTime(dateTime);
return dt.compareTo(endDateTime) >= 0;
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Is this period starts after the specified temporal?
* @param dateTime either a date or a date time. Any other temporal type isn't supported.
* @return true if this period's start date is after the specified temporal (the period's
* start date is inclusive).
*/
public boolean startsAfter(final Temporal dateTime) {
OffsetDateTime dt = asOffsetDateTime(dateTime);
return dt.compareTo(startDateTime) < 0;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.hibernate-validator
@Override
public boolean isValid(OffsetDateTime value, ConstraintValidatorContext context) {
// null values are valid
if ( value == null ) {
return true;
}
TimeProvider timeProvider = context.unwrap( HibernateConstraintValidatorContext.class )
.getTimeProvider();
OffsetDateTime reference = OffsetDateTime.ofInstant( Instant.ofEpochMilli( timeProvider.getCurrentTime() ), value.getOffset() );
return value.compareTo( reference ) < 0;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.hibernate-validator
@Override
public boolean isValid(OffsetDateTime value, ConstraintValidatorContext context) {
// null values are valid
if ( value == null ) {
return true;
}
TimeProvider timeProvider = context.unwrap( HibernateConstraintValidatorContext.class )
.getTimeProvider();
OffsetDateTime reference = OffsetDateTime.ofInstant( Instant.ofEpochMilli( timeProvider.getCurrentTime() ), value.getOffset() );
return value.compareTo( reference ) > 0;
}
}
代码示例来源:origin: it.ozimov/spring-boot-email-core
private boolean beforeLastLoadedFromPersistenceLayer(final EmailSchedulingData emailSchedulingData) {
if (!hasPersistence || !hasElements()) {
return true;
}
final EmailSchedulingData least = getLeastOfAllLast().get();
final int scheduledDateTimeComparison = emailSchedulingData.getScheduledDateTime().compareTo(least.getScheduledDateTime().plus(queuabilityDelta));
return scheduledDateTimeComparison < 0 || (scheduledDateTimeComparison == 0 && emailSchedulingData.getAssignedPriority() < least.getAssignedPriority());
}
代码示例来源:origin: ozimov/spring-boot-email-tools
private boolean beforeLastLoadedFromPersistenceLayer(final EmailSchedulingData emailSchedulingData) {
if (!hasPersistence || !hasElements()) {
return true;
}
final EmailSchedulingData least = getLeastOfAllLast().get();
final int scheduledDateTimeComparison = emailSchedulingData.getScheduledDateTime().compareTo(least.getScheduledDateTime().plus(queuabilityDelta));
return scheduledDateTimeComparison < 0 || (scheduledDateTimeComparison == 0 && emailSchedulingData.getAssignedPriority() < least.getAssignedPriority());
}
代码示例来源:origin: com.pholser/junit-quickcheck-generators
/**
* <p>Tells this generator to produce values within a specified
* {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
* maximum}, inclusive, with uniform distribution, down to the
* nanosecond.</p>
*
* <p>If an endpoint of the range is not specified, the generator will use
* dates with values of either {@link OffsetDateTime#MIN} or
* {@link OffsetDateTime#MAX} as appropriate.</p>
*
* <p>{@link InRange#format()} describes
* {@linkplain DateTimeFormatter#ofPattern(String) how the generator is to
* interpret the range's endpoints}.</p>
*
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(range.format());
if (!defaultValueOf(InRange.class, "min").equals(range.min()))
min = OffsetDateTime.parse(range.min(), formatter);
if (!defaultValueOf(InRange.class, "max").equals(range.max()))
max = OffsetDateTime.parse(range.max(), formatter);
if (min.compareTo(max) > 0)
throw new IllegalArgumentException(String.format("bad range, %s > %s", range.min(), range.max()));
}
代码示例来源:origin: org.openbase.bco/ontology.lib
final OffsetDateTime lastHeartbeat = OffsetDateTime.parse(lastTimeStamp).plusSeconds(OntConfig.HEART_BEAT_TOLERANCE);
if (lastHeartbeat.compareTo(now) >= 0) {
内容来源于网络,如有侵权,请联系作者删除!