本文整理了Java中java.time.OffsetDateTime.equals()
方法的一些代码示例,展示了OffsetDateTime.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.equals()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:equals
[英]Checks if this date-time is equal to another date-time.
The comparison is based on the local date-time and the offset. To compare for the same instant on the time-line, use #isEqual. Only objects of type OffsetDateTime are compared, other types return false.
[中]检查此日期时间是否等于另一个日期时间。
比较基于本地日期时间和偏移量。要在时间线上对同一时刻进行比较,请使用#isEqual。仅比较OffsetDateTime类型的对象,其他类型返回false。
代码示例来源:origin: org.postgresql/postgresql
public synchronized String toString(OffsetDateTime offsetDateTime) {
if (offsetDateTime.isAfter(MAX_OFFSET_DATETIME)) {
return "infinity";
} else if (OffsetDateTime.MIN.equals(offsetDateTime)) {
return "-infinity";
}
sbuf.setLength(0);
int nano = offsetDateTime.getNano();
if (nanosExceed499(nano)) {
// Technically speaking this is not a proper rounding, however
// it relies on the fact that appendTime just truncates 000..999 nanosecond part
offsetDateTime = offsetDateTime.plus(ONE_MICROSECOND);
}
LocalDateTime localDateTime = offsetDateTime.toLocalDateTime();
LocalDate localDate = localDateTime.toLocalDate();
appendDate(sbuf, localDate);
sbuf.append(' ');
appendTime(sbuf, localDateTime.toLocalTime());
appendTimeZone(sbuf, offsetDateTime.getOffset());
appendEra(sbuf, localDate);
return sbuf.toString();
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Period)) {
return false;
}
final Period period = (Period) o;
return inDays == period.inDays && startDateTime.equals(period.startDateTime) &&
endDateTime.equals(period.endDateTime);
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
private boolean sameEndTimeAs(final Recurrence recurrence) {
return (recurrence.endDateTime == NO_RECURRENCE_END_DATE && this.endDateTime == NO_RECURRENCE_END_DATE) ||
(recurrence.endDateTime != NO_RECURRENCE_END_DATE && recurrence.endDateTime.equals(this.endDateTime));
}
代码示例来源:origin: signaflo/java-timeseries
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Time time = (Time) o;
return dateTime.equals(time.dateTime);
}
代码示例来源:origin: otto-de/edison-microservice
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JobMessage that = (JobMessage) o;
if (level != that.level) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) return false;
return true;
}
代码示例来源:origin: otto-de/edison-microservice
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JobInfo jobInfo = (JobInfo) o;
if (jobType != null ? !jobType.equals(jobInfo.jobType) : jobInfo.jobType != null) return false;
if (jobId != null ? !jobId.equals(jobInfo.jobId) : jobInfo.jobId != null) return false;
if (lastUpdated != null ? !lastUpdated.equals(jobInfo.lastUpdated) : jobInfo.lastUpdated != null) return false;
if (messages != null ? !messages.equals(jobInfo.messages) : jobInfo.messages != null) return false;
if (started != null ? !started.equals(jobInfo.started) : jobInfo.started != null) return false;
if (status != jobInfo.status) return false;
if (stopped != null ? !stopped.equals(jobInfo.stopped) : jobInfo.stopped != null) return false;
if (hostname != null ? !hostname.equals(jobInfo.hostname) : jobInfo.hostname != null) return false;
return true;
}
代码示例来源:origin: com.microsoft.rest.v2/client-runtime
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof DateTimeRfc1123)) {
return false;
}
DateTimeRfc1123 rhs = (DateTimeRfc1123) obj;
return this.dateTime.equals(rhs.dateTime());
}
}
代码示例来源:origin: com.microsoft.rest.v2/client-runtime
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof UnixTime)) {
return false;
}
UnixTime rhs = (UnixTime) obj;
return this.dateTime.equals(rhs.dateTime());
}
}
代码示例来源:origin: openmhealth/schemas
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
DataPointAcquisitionProvenance that = (DataPointAcquisitionProvenance) object;
if (!sourceName.equals(that.sourceName)) {
return false;
}
if (sourceCreationDateTime != null ? !sourceCreationDateTime.equals(that.sourceCreationDateTime)
: that.sourceCreationDateTime != null) {
return false;
}
return modality == that.modality;
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
@Override
public Timestamp convertToDatabaseColumn(OffsetDateTime dateTime) {
if (dateTime == null) {
return null;
}
if (dateTime.equals(OffsetDateTime.MIN)) {
return MIN_TIMESTAMP;
}
if (dateTime.equals(OffsetDateTime.MAX)) {
return MAX_TIMESTAMP;
}
return Timestamp.valueOf(dateTime.withOffsetSameInstant(ZoneOffset.UTC).toLocalDateTime());
}
代码示例来源:origin: openmhealth/schemas
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
TimeFrame timeFrame = (TimeFrame) object;
if (timeInterval != null ? !timeInterval.equals(timeFrame.timeInterval) : timeFrame.timeInterval != null) {
return false;
}
return !(dateTime != null ? !dateTime.equals(timeFrame.dateTime) : timeFrame.dateTime != null);
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
@Override
protected void encodeValue(Context context, Type type, Object value, Object sourceContext, StringBuilder buffer) throws IOException {
Calendar calendar = sourceContext != null ? (Calendar) sourceContext : Calendar.getInstance();
OffsetDateTime dateTime = convertInput(context, type, value, calendar);
if (dateTime.equals(OffsetDateTime.MAX)) {
buffer.append(POS_INFINITY);
}
else if (dateTime.equals(OffsetDateTime.MIN)) {
buffer.append(NEG_INFINITY);
}
else {
String strVal = context.getTimestampFormat().getPrinter().format(dateTime);
buffer.append(strVal);
}
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Recurrence)) {
return false;
}
final Recurrence that = (Recurrence) o;
if (this.count != that.count || !frequency.equals(that.frequency)) {
return false;
}
if (this.endDateTime != null) {
if (!this.endDateTime.equals(that.endDateTime)) {
return false;
}
} else if (that.endDateTime != null) {
return false;
}
return daysOfWeek.equals(that.daysOfWeek) && exceptionDates.equals(that.exceptionDates);
}
代码示例来源:origin: openmhealth/schemas
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
TimeInterval that = (TimeInterval) object;
if (startDateTime != null ? !startDateTime.equals(that.startDateTime) : that.startDateTime != null) {
return false;
}
if (endDateTime != null ? !endDateTime.equals(that.endDateTime) : that.endDateTime != null) {
return false;
}
if (duration != null ? !duration.equals(that.duration) : that.duration != null) {
return false;
}
if (date != null ? !date.equals(that.date) : that.date != null) {
return false;
}
return partOfDay == that.partOfDay;
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
@Override
protected void encodeValue(Context context, Type type, Object value, Object sourceContext, ByteBuf buffer) throws IOException {
Calendar calendar = sourceContext != null ? (Calendar) sourceContext : Calendar.getInstance();
OffsetDateTime dateTime = convertInput(context, type, value, calendar);
long micros;
if (dateTime.equals(OffsetDateTime.MAX)) {
micros = Long.MAX_VALUE;
}
else if (dateTime.equals(OffsetDateTime.MIN)) {
micros = Long.MIN_VALUE;
}
else {
long seconds = javaEpochToPg(dateTime.toEpochSecond(), SECONDS);
// Convert to micros rounding nanoseconds
micros = SECONDS.toMicros(seconds) + NANOSECONDS.toMicros(dateTime.getNano() + 500);
}
buffer.writeLong(micros);
}
代码示例来源:origin: org.pageseeder.bridge/pso-bridge
/**
* A convenience method to return a copy of this member with the specified last login.
*
* @return a new member with the specified last login if the last login is different from that of the current member
*/
public Member lastLogin(@NonNull OffsetDateTime lastLogin ) {
if (lastLogin.equals(this._lastLogin)) return this;
return new Member(this._id, this._username, this._email, this._firstname, this._surname, this._status, this._locked, this._onVacation, this._attachments, lastLogin);
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Is this period starts at the the minimum supported date/datetime in Java?
* @return true if this period starts at the minimum date/datetime supported by Java.
* False otherwise.
* @see LocalDate#MIN for the minimum supported date.
* @see OffsetDateTime#MIN for the maximum supported date.
*/
public boolean startsAtMinDate() {
return startDateTime.withOffsetSameInstant(OffsetDateTime.MIN.getOffset())
.equals(OffsetDateTime.MIN);
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Is this period ends at the the maximum supported date/datetime in Java?
* @return true if this period ends at the minimum date/datetime supported by Java.
* False otherwise.
* @see LocalDate#MAX for the maximum supported datetime.
* @see OffsetDateTime#MAX for the maximum supported datetime.
*/
public boolean endsAtMaxDate() {
return endDateTime.withOffsetSameInstant(OffsetDateTime.MAX.getOffset())
.equals(OffsetDateTime.MAX);
}
代码示例来源:origin: openmhealth/schemas
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
DataPointHeader that = (DataPointHeader) object;
if (!id.equals(that.id)) {
return false;
}
if (!creationDateTime.equals(that.creationDateTime)) {
return false;
}
if (!bodySchemaId.equals(that.bodySchemaId)) {
return false;
}
if (acquisitionProvenance != null ? !acquisitionProvenance.equals(that.acquisitionProvenance)
: that.acquisitionProvenance != null) {
return false;
}
return !(userId != null ? !userId.equals(that.userId) : that.userId != null);
}
代码示例来源:origin: org.pageseeder.flint/pso-flint-lucene
private Interval findInterval(OffsetDateTime date) {
// go forwards or backwards?
boolean forward = date.isAfter(this._start);
OffsetDateTime from = this._start;
while (true) {
OffsetDateTime to = next(from, forward);
OffsetDateTime lower = forward ? from : to;
OffsetDateTime upper = forward ? to : from;
// make sure we're still within limits
if (this._end != null) {
if (lower.isAfter(this._end) || lower.equals(this._end) ||
upper.isBefore(this._start) || upper.equals(this._start))
return null;
}
boolean includeMax = this._end != null && to.equals(next(to, forward)) ? includeLastUpper() : !includeLower();
boolean lowerLimit = date.isAfter(lower) || (includeLower() && date.equals(lower));
boolean upperLimit = date.isBefore(upper) || (includeMax && date.equals(upper));
if (lowerLimit && upperLimit) {
return Interval.dateInterval(new Date(lower.toEpochSecond() * 1000), includeLower(), new Date(upper.toEpochSecond() * 1000), includeMax, this._resolution);
}
// safety checks
if (forward && upperLimit) return null;
if (!forward && lowerLimit) return null;
if (from.equals(to)) return null;
from = to;
}
}
内容来源于网络,如有侵权,请联系作者删除!