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

x33g5p2x  于2022-01-23 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(128)

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

LocalTime.equals介绍

[英]Checks if this time is equal to another time.

The comparison is based on the time-line position of the time within a day.

Only objects of type LocalTime are compared, other types return false. To compare the date of two TemporalAccessor instances, use ChronoField#NANO_OF_DAY as a comparator.
[中]检查此时间是否等于其他时间。
比较基于一天内时间的时间线位置。
仅比较LocalTime类型的对象,其他类型返回false。要比较两个TemporalAccessor实例的日期,请使用ChronoField#NANO_of_DAY作为比较器。

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
public boolean equals( Value other )
{
  return other instanceof LocalTimeValue && value.equals( ((LocalTimeValue) other).value );
}

代码示例来源:origin: MorphiaOrg/morphia

@Override
public boolean equals(final Object o) {
  if (this == o) {
    return true;
  }
  if (!(o instanceof Java8Entity)) {
    return false;
  }
  final Java8Entity that = (Java8Entity) o;
  if (id != null ? !id.equals(that.id) : that.id != null) {
    return false;
  }
  if (instant != null ? !instant.equals(that.instant) : that.instant != null) {
    return false;
  }
  if (localDate != null ? !localDate.equals(that.localDate) : that.localDate != null) {
    return false;
  }
  if (localDateTime != null ? !localDateTime.equals(that.localDateTime) : that.localDateTime != null) {
    return false;
  }
  return localTime != null ? localTime.equals(that.localTime) : that.localTime == null;
}

代码示例来源:origin: jtablesaw/tablesaw

@Test
  public void testAtTime() {
    column1.appendCell("2013-10-23");
    column1.appendCell("12/24/1924");
    column1.appendCell("12-May-2015");
    column1.appendCell("14-Jan-2015");

    DateTimeColumn dateTimes = column1.atTime(LocalTime.NOON);
    assertNotNull(dateTimes);
    assertTrue(dateTimes.get(0).toLocalTime().equals(LocalTime.NOON));
  }
}

代码示例来源:origin: jtablesaw/tablesaw

@Test
public void testAtTimeColumn() {
  column1.appendCell("2013-10-23");
  column1.appendCell("12/24/1924");
  column1.appendCell("12-May-2015");
  column1.appendCell("14-Jan-2015");
  TimeColumn timeColumn = TimeColumn.create("times");
  timeColumn.append(LocalTime.NOON);
  timeColumn.append(LocalTime.NOON);
  timeColumn.append(LocalTime.NOON);
  timeColumn.append(LocalTime.NOON);
  DateTimeColumn dateTimes = column1.atTime(timeColumn);
  assertNotNull(dateTimes);
  assertTrue(dateTimes.get(0).toLocalTime().equals(LocalTime.NOON));
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

public static boolean isSameLocalTime(LocalTime first, LocalTime second) {
  // If both values are null, return true.
  if (first == null && second == null) {
    return true;
  }
  // At least one value contains a time. If the other value is null, then return false.
  if (first == null || second == null) {
    return false;
  }
  // Both values contain times. Return true if the times are equal, otherwise return false.
  return first.equals(second);
}

代码示例来源:origin: org.neo4j/neo4j-values

@Override
public boolean equals( Value other )
{
  return other instanceof LocalTimeValue && value.equals( ((LocalTimeValue) other).value );
}

代码示例来源:origin: eXparity/hamcrest-date

@Override
public boolean isSame(final LocalTime other) {
  return wrapped.equals(other);
}

代码示例来源:origin: com.github.almex/raildelays-api

@Override
public boolean equals(Object obj) {
  boolean result = false;
  if (obj == this) {
    result = true;
  } else if (obj instanceof TimeDelay) {
    TimeDelay target = (TimeDelay) obj;
    result = this.expectedTime.equals(target.expectedTime) && this.delay.equals(target.delay);
  }
  return result;
}

代码示例来源:origin: citygml4j/citygml4j

@Override
public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context) {
  // return "date-time" only if the time is not set to start of day
  DateTimeFormatter formatter = src.toLocalTime().equals(LocalTime.MIN) ?
      DateTimeFormatter.ISO_LOCAL_DATE : DateTimeFormatter.ISO_OFFSET_DATE_TIME;
  return new JsonPrimitive(src.format(formatter));
}

代码示例来源:origin: com.github.wslotkin/itinerator-generator

private boolean equalTo(ImmutableWeeklyTimePoint another) {
 return dayOfWeek.equals(another.dayOfWeek)
   && timeOfDay.equals(another.timeOfDay);
}

代码示例来源:origin: quickfix-j/quickfixj

public boolean valueEquals(LocalTime value) {
  return getValue().equals(value);
}

代码示例来源:origin: lesfurets/dOOv

@Override
BiFunction<LocalTime, LocalTime, Boolean> afterOrEqualsFunction() {
  return (time1, time2) -> time1.isAfter(time2) || time1.equals(time2);
}

代码示例来源:origin: quickfix-j/quickfixj

public boolean valueEquals(LocalTime value) {
  return getValue().equals(value);
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

int indexOf(LocalTime current) {
 if (current.isBefore(this.start)) {
  return -1;
 } else if ((current.isAfter(this.start) || current.equals(this.start)) && (current.isBefore(this.end) || current.equals(this.end))) {
  return 0;
 } else {
  return 1;
 }
}

代码示例来源:origin: com.healthmarketscience.jackcess/jackcess

public static Value.Type getDateTimeType(LocalDateTime ldt) {
 boolean hasDate = !ColumnImpl.BASE_LD.equals(ldt.toLocalDate());
 boolean hasTime = !ColumnImpl.BASE_LT.equals(ldt.toLocalTime());
 return (hasDate ?
     (hasTime ? Value.Type.DATE_TIME : Value.Type.DATE) :
     Value.Type.TIME);
}

代码示例来源:origin: stackoverflow.com

LocalDateTime from = LocalDateTime.parse("2015-07-24T09:39:14.000Z", DateTimeFormatter.ISO_DATE_TIME);
LocalDateTime to = LocalDateTime.parse("2015-07-24T09:45:44.000Z", DateTimeFormatter.ISO_DATE_TIME);
System.out.println(from + " - " + to);

LocalTime fromTime = from.toLocalTime();
LocalTime toTime = to.toLocalTime();

System.out.println(fromTime + " - " + toTime);

System.out.println(fromTime + " before " + toTime + " = " + fromTime.isBefore(toTime));
System.out.println(fromTime + " after " + toTime + " = " + fromTime.isAfter(toTime));
System.out.println(fromTime + " equals " + toTime + " = " + fromTime.equals(toTime));
System.out.println(fromTime + " compareTo " + toTime + " = " + fromTime.compareTo(toTime));

代码示例来源:origin: stackoverflow.com

static boolean isInRange(LocalTime start, LocalTime end, LocalTime value) {
  // Avoid equality problems - see description
  if (value.equals(start) || value.equals(end)) {
    return true;
  }
  if (start.compareTo(end) > 0) {
    return !isInRange(end, start, value);
  }
  return start.compareTo(value) < 0 && value.compareTo(end) < 0;
}

代码示例来源:origin: com.torodb.engine.kvdocument/kvdocument-core

@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (obj == null) {
  return false;
 }
 if (!(obj instanceof KvTime)) {
  return false;
 }
 return this.getValue().equals(((KvTime) obj).getValue());
}

代码示例来源:origin: stackoverflow.com

LocalTime openingTime = LocalTime.parse ( "04:00" );
LocalTime closingTime = LocalTime.parse ( "00:00" );
Boolean inRange = null;
LocalTime target = LocalTime.MIDNIGHT; // LocalTime.of ( 3 , 0) or LocalTime.of ( 4 , 0) or LocalTime.of ( 5 , 0) or LocalTime.now ( ZoneId.of ( "America/Los_Angeles" ) );
if ( closingTime.equals ( LocalTime.MIDNIGHT ) ) {
  inRange = (  ! target.isBefore ( openingTime ) );
} else {
  inRange = ( (  ! target.isBefore ( openingTime ) ) && ( target.isBefore ( closingTime ) ) );
}

代码示例来源:origin: epam/DLab

private boolean areSchedulersEqualForSyncStarting(SchedulerJobDTO notebookScheduler,
                         SchedulerJobDTO clusterScheduler) {
  return !Objects.isNull(notebookScheduler) && !Objects.isNull(clusterScheduler) &&
      notebookScheduler.getBeginDate().equals(clusterScheduler.getBeginDate()) &&
      notebookScheduler.getStartTime().equals(clusterScheduler.getStartTime()) &&
      areCollectionsEqual(notebookScheduler.getStartDaysRepeat(), clusterScheduler.getStartDaysRepeat())
      && notebookScheduler.getTimeZoneOffset().equals(clusterScheduler.getTimeZoneOffset()) &&
      notebookScheduler.isSyncStartRequired() && clusterScheduler.isSyncStartRequired();
}

相关文章