java.time.OffsetDateTime.equals()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中java.time.OffsetDateTime.equals()方法的一些代码示例,展示了OffsetDateTime.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.equals()方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:equals

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

  1. public synchronized String toString(OffsetDateTime offsetDateTime) {
  2. if (offsetDateTime.isAfter(MAX_OFFSET_DATETIME)) {
  3. return "infinity";
  4. } else if (OffsetDateTime.MIN.equals(offsetDateTime)) {
  5. return "-infinity";
  6. }
  7. sbuf.setLength(0);
  8. int nano = offsetDateTime.getNano();
  9. if (nanosExceed499(nano)) {
  10. // Technically speaking this is not a proper rounding, however
  11. // it relies on the fact that appendTime just truncates 000..999 nanosecond part
  12. offsetDateTime = offsetDateTime.plus(ONE_MICROSECOND);
  13. }
  14. LocalDateTime localDateTime = offsetDateTime.toLocalDateTime();
  15. LocalDate localDate = localDateTime.toLocalDate();
  16. appendDate(sbuf, localDate);
  17. sbuf.append(' ');
  18. appendTime(sbuf, localDateTime.toLocalTime());
  19. appendTimeZone(sbuf, offsetDateTime.getOffset());
  20. appendEra(sbuf, localDate);
  21. return sbuf.toString();
  22. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. @Override
  2. public boolean equals(final Object o) {
  3. if (this == o) {
  4. return true;
  5. }
  6. if (!(o instanceof Period)) {
  7. return false;
  8. }
  9. final Period period = (Period) o;
  10. return inDays == period.inDays && startDateTime.equals(period.startDateTime) &&
  11. endDateTime.equals(period.endDateTime);
  12. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. private boolean sameEndTimeAs(final Recurrence recurrence) {
  2. return (recurrence.endDateTime == NO_RECURRENCE_END_DATE && this.endDateTime == NO_RECURRENCE_END_DATE) ||
  3. (recurrence.endDateTime != NO_RECURRENCE_END_DATE && recurrence.endDateTime.equals(this.endDateTime));
  4. }

代码示例来源:origin: signaflo/java-timeseries

  1. @Override
  2. public boolean equals(Object o) {
  3. if (this == o) {
  4. return true;
  5. }
  6. if (o == null || getClass() != o.getClass()) {
  7. return false;
  8. }
  9. Time time = (Time) o;
  10. return dateTime.equals(time.dateTime);
  11. }

代码示例来源:origin: otto-de/edison-microservice

  1. @Override
  2. public boolean equals(Object o) {
  3. if (this == o) return true;
  4. if (o == null || getClass() != o.getClass()) return false;
  5. JobMessage that = (JobMessage) o;
  6. if (level != that.level) return false;
  7. if (message != null ? !message.equals(that.message) : that.message != null) return false;
  8. if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) return false;
  9. return true;
  10. }

代码示例来源:origin: otto-de/edison-microservice

  1. @Override
  2. public boolean equals(Object o) {
  3. if (this == o) return true;
  4. if (o == null || getClass() != o.getClass()) return false;
  5. JobInfo jobInfo = (JobInfo) o;
  6. if (jobType != null ? !jobType.equals(jobInfo.jobType) : jobInfo.jobType != null) return false;
  7. if (jobId != null ? !jobId.equals(jobInfo.jobId) : jobInfo.jobId != null) return false;
  8. if (lastUpdated != null ? !lastUpdated.equals(jobInfo.lastUpdated) : jobInfo.lastUpdated != null) return false;
  9. if (messages != null ? !messages.equals(jobInfo.messages) : jobInfo.messages != null) return false;
  10. if (started != null ? !started.equals(jobInfo.started) : jobInfo.started != null) return false;
  11. if (status != jobInfo.status) return false;
  12. if (stopped != null ? !stopped.equals(jobInfo.stopped) : jobInfo.stopped != null) return false;
  13. if (hostname != null ? !hostname.equals(jobInfo.hostname) : jobInfo.hostname != null) return false;
  14. return true;
  15. }

代码示例来源:origin: com.microsoft.rest.v2/client-runtime

  1. @Override
  2. public boolean equals(Object obj) {
  3. if (obj == null) {
  4. return false;
  5. }
  6. if (!(obj instanceof DateTimeRfc1123)) {
  7. return false;
  8. }
  9. DateTimeRfc1123 rhs = (DateTimeRfc1123) obj;
  10. return this.dateTime.equals(rhs.dateTime());
  11. }
  12. }

代码示例来源:origin: com.microsoft.rest.v2/client-runtime

  1. @Override
  2. public boolean equals(Object obj) {
  3. if (obj == null) {
  4. return false;
  5. }
  6. if (!(obj instanceof UnixTime)) {
  7. return false;
  8. }
  9. UnixTime rhs = (UnixTime) obj;
  10. return this.dateTime.equals(rhs.dateTime());
  11. }
  12. }

代码示例来源:origin: openmhealth/schemas

  1. @SuppressWarnings("SimplifiableIfStatement")
  2. @Override
  3. public boolean equals(Object object) {
  4. if (this == object) {
  5. return true;
  6. }
  7. if (object == null || getClass() != object.getClass()) {
  8. return false;
  9. }
  10. DataPointAcquisitionProvenance that = (DataPointAcquisitionProvenance) object;
  11. if (!sourceName.equals(that.sourceName)) {
  12. return false;
  13. }
  14. if (sourceCreationDateTime != null ? !sourceCreationDateTime.equals(that.sourceCreationDateTime)
  15. : that.sourceCreationDateTime != null) {
  16. return false;
  17. }
  18. return modality == that.modality;
  19. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. @Override
  2. public Timestamp convertToDatabaseColumn(OffsetDateTime dateTime) {
  3. if (dateTime == null) {
  4. return null;
  5. }
  6. if (dateTime.equals(OffsetDateTime.MIN)) {
  7. return MIN_TIMESTAMP;
  8. }
  9. if (dateTime.equals(OffsetDateTime.MAX)) {
  10. return MAX_TIMESTAMP;
  11. }
  12. return Timestamp.valueOf(dateTime.withOffsetSameInstant(ZoneOffset.UTC).toLocalDateTime());
  13. }

代码示例来源:origin: openmhealth/schemas

  1. @SuppressWarnings("SimplifiableIfStatement")
  2. @Override
  3. public boolean equals(Object object) {
  4. if (this == object) {
  5. return true;
  6. }
  7. if (object == null || getClass() != object.getClass()) {
  8. return false;
  9. }
  10. TimeFrame timeFrame = (TimeFrame) object;
  11. if (timeInterval != null ? !timeInterval.equals(timeFrame.timeInterval) : timeFrame.timeInterval != null) {
  12. return false;
  13. }
  14. return !(dateTime != null ? !dateTime.equals(timeFrame.dateTime) : timeFrame.dateTime != null);
  15. }

代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng

  1. @Override
  2. protected void encodeValue(Context context, Type type, Object value, Object sourceContext, StringBuilder buffer) throws IOException {
  3. Calendar calendar = sourceContext != null ? (Calendar) sourceContext : Calendar.getInstance();
  4. OffsetDateTime dateTime = convertInput(context, type, value, calendar);
  5. if (dateTime.equals(OffsetDateTime.MAX)) {
  6. buffer.append(POS_INFINITY);
  7. }
  8. else if (dateTime.equals(OffsetDateTime.MIN)) {
  9. buffer.append(NEG_INFINITY);
  10. }
  11. else {
  12. String strVal = context.getTimestampFormat().getPrinter().format(dateTime);
  13. buffer.append(strVal);
  14. }
  15. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. @Override
  2. public boolean equals(final Object o) {
  3. if (this == o) {
  4. return true;
  5. }
  6. if (!(o instanceof Recurrence)) {
  7. return false;
  8. }
  9. final Recurrence that = (Recurrence) o;
  10. if (this.count != that.count || !frequency.equals(that.frequency)) {
  11. return false;
  12. }
  13. if (this.endDateTime != null) {
  14. if (!this.endDateTime.equals(that.endDateTime)) {
  15. return false;
  16. }
  17. } else if (that.endDateTime != null) {
  18. return false;
  19. }
  20. return daysOfWeek.equals(that.daysOfWeek) && exceptionDates.equals(that.exceptionDates);
  21. }

代码示例来源:origin: openmhealth/schemas

  1. @SuppressWarnings("SimplifiableIfStatement")
  2. @Override
  3. public boolean equals(Object object) {
  4. if (this == object) {
  5. return true;
  6. }
  7. if (object == null || getClass() != object.getClass()) {
  8. return false;
  9. }
  10. TimeInterval that = (TimeInterval) object;
  11. if (startDateTime != null ? !startDateTime.equals(that.startDateTime) : that.startDateTime != null) {
  12. return false;
  13. }
  14. if (endDateTime != null ? !endDateTime.equals(that.endDateTime) : that.endDateTime != null) {
  15. return false;
  16. }
  17. if (duration != null ? !duration.equals(that.duration) : that.duration != null) {
  18. return false;
  19. }
  20. if (date != null ? !date.equals(that.date) : that.date != null) {
  21. return false;
  22. }
  23. return partOfDay == that.partOfDay;
  24. }

代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng

  1. @Override
  2. protected void encodeValue(Context context, Type type, Object value, Object sourceContext, ByteBuf buffer) throws IOException {
  3. Calendar calendar = sourceContext != null ? (Calendar) sourceContext : Calendar.getInstance();
  4. OffsetDateTime dateTime = convertInput(context, type, value, calendar);
  5. long micros;
  6. if (dateTime.equals(OffsetDateTime.MAX)) {
  7. micros = Long.MAX_VALUE;
  8. }
  9. else if (dateTime.equals(OffsetDateTime.MIN)) {
  10. micros = Long.MIN_VALUE;
  11. }
  12. else {
  13. long seconds = javaEpochToPg(dateTime.toEpochSecond(), SECONDS);
  14. // Convert to micros rounding nanoseconds
  15. micros = SECONDS.toMicros(seconds) + NANOSECONDS.toMicros(dateTime.getNano() + 500);
  16. }
  17. buffer.writeLong(micros);
  18. }

代码示例来源:origin: org.pageseeder.bridge/pso-bridge

  1. /**
  2. * A convenience method to return a copy of this member with the specified last login.
  3. *
  4. * @return a new member with the specified last login if the last login is different from that of the current member
  5. */
  6. public Member lastLogin(@NonNull OffsetDateTime lastLogin ) {
  7. if (lastLogin.equals(this._lastLogin)) return this;
  8. return new Member(this._id, this._username, this._email, this._firstname, this._surname, this._status, this._locked, this._onVacation, this._attachments, lastLogin);
  9. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * Is this period starts at the the minimum supported date/datetime in Java?
  3. * @return true if this period starts at the minimum date/datetime supported by Java.
  4. * False otherwise.
  5. * @see LocalDate#MIN for the minimum supported date.
  6. * @see OffsetDateTime#MIN for the maximum supported date.
  7. */
  8. public boolean startsAtMinDate() {
  9. return startDateTime.withOffsetSameInstant(OffsetDateTime.MIN.getOffset())
  10. .equals(OffsetDateTime.MIN);
  11. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * Is this period ends at the the maximum supported date/datetime in Java?
  3. * @return true if this period ends at the minimum date/datetime supported by Java.
  4. * False otherwise.
  5. * @see LocalDate#MAX for the maximum supported datetime.
  6. * @see OffsetDateTime#MAX for the maximum supported datetime.
  7. */
  8. public boolean endsAtMaxDate() {
  9. return endDateTime.withOffsetSameInstant(OffsetDateTime.MAX.getOffset())
  10. .equals(OffsetDateTime.MAX);
  11. }

代码示例来源:origin: openmhealth/schemas

  1. @SuppressWarnings("SimplifiableIfStatement")
  2. @Override
  3. public boolean equals(Object object) {
  4. if (this == object) {
  5. return true;
  6. }
  7. if (object == null || getClass() != object.getClass()) {
  8. return false;
  9. }
  10. DataPointHeader that = (DataPointHeader) object;
  11. if (!id.equals(that.id)) {
  12. return false;
  13. }
  14. if (!creationDateTime.equals(that.creationDateTime)) {
  15. return false;
  16. }
  17. if (!bodySchemaId.equals(that.bodySchemaId)) {
  18. return false;
  19. }
  20. if (acquisitionProvenance != null ? !acquisitionProvenance.equals(that.acquisitionProvenance)
  21. : that.acquisitionProvenance != null) {
  22. return false;
  23. }
  24. return !(userId != null ? !userId.equals(that.userId) : that.userId != null);
  25. }

代码示例来源:origin: org.pageseeder.flint/pso-flint-lucene

  1. private Interval findInterval(OffsetDateTime date) {
  2. // go forwards or backwards?
  3. boolean forward = date.isAfter(this._start);
  4. OffsetDateTime from = this._start;
  5. while (true) {
  6. OffsetDateTime to = next(from, forward);
  7. OffsetDateTime lower = forward ? from : to;
  8. OffsetDateTime upper = forward ? to : from;
  9. // make sure we're still within limits
  10. if (this._end != null) {
  11. if (lower.isAfter(this._end) || lower.equals(this._end) ||
  12. upper.isBefore(this._start) || upper.equals(this._start))
  13. return null;
  14. }
  15. boolean includeMax = this._end != null && to.equals(next(to, forward)) ? includeLastUpper() : !includeLower();
  16. boolean lowerLimit = date.isAfter(lower) || (includeLower() && date.equals(lower));
  17. boolean upperLimit = date.isBefore(upper) || (includeMax && date.equals(upper));
  18. if (lowerLimit && upperLimit) {
  19. return Interval.dateInterval(new Date(lower.toEpochSecond() * 1000), includeLower(), new Date(upper.toEpochSecond() * 1000), includeMax, this._resolution);
  20. }
  21. // safety checks
  22. if (forward && upperLimit) return null;
  23. if (!forward && lowerLimit) return null;
  24. if (from.equals(to)) return null;
  25. from = to;
  26. }
  27. }

相关文章