java.time.ZonedDateTime.isEqual()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(116)

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

ZonedDateTime.isEqual介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private void checkSavedZonedDateTimeIsEqual(ZonedDateTime startdate) {
  final Session s = openSession();
  try {
    final ZonedDateTimeEvent zonedDateTimeEvent = s.get( ZonedDateTimeEvent.class, 1L );
    assertThat( zonedDateTimeEvent.startDate.isEqual( startdate ), is( true ) );
  }
  finally {
    s.close();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void firstZonedDateTime() {
  ZonedDateTime date = ZonedDateTime.of(2017, 6, 22, 22, 22, 0, 0, ZoneId.of("GMT"));
  headers.setZonedDateTime(HttpHeaders.DATE, date);
  assertThat(headers.getFirst(HttpHeaders.DATE), is("Thu, 22 Jun 2017 22:22:00 GMT"));
  assertTrue(headers.getFirstZonedDateTime(HttpHeaders.DATE).isEqual(date));
  headers.clear();
  ZonedDateTime otherDate = ZonedDateTime.of(2010, 12, 18, 10, 20, 0, 0, ZoneId.of("GMT"));
  headers.add(HttpHeaders.DATE, RFC_1123_DATE_TIME.format(date));
  headers.add(HttpHeaders.DATE, RFC_1123_DATE_TIME.format(otherDate));
  assertTrue(headers.getFirstZonedDateTime(HttpHeaders.DATE).isEqual(date));
  // obsolete RFC 850 format
  headers.clear();
  headers.set(HttpHeaders.DATE, "Thursday, 22-Jun-17 22:22:00 GMT");
  assertTrue(headers.getFirstZonedDateTime(HttpHeaders.DATE).isEqual(date));
  // ANSI C's asctime() format
  headers.clear();
  headers.set(HttpHeaders.DATE, "Thu Jun 22 22:22:00 2017");
  assertTrue(headers.getFirstZonedDateTime(HttpHeaders.DATE).isEqual(date));
}

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

@Test
public void zonedDateTimeLosesZone() {
  ZonedDateTime dt = ZonedDateTime.now().withZoneSameInstant(ZoneId.of("America/Denver"));
  h.execute("insert into stuff(ts) values (?)", dt);
  assertThat(h.createQuery("select ts from stuff").mapTo(ZonedDateTime.class).findOnly().isEqual(dt)).isTrue();
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public boolean isEqual(JodaCompatibleZonedDateTime o) {
  return dt.isEqual(o.getZonedDateTime());
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneOffset() {
 Map<String, Object> parserConfig = new HashMap<>();
 parserConfig.put("deviceTimeZone", "UTC-05:00");
 Syslog5424Parser testParser = new Syslog5424Parser();
 testParser.configure(parserConfig);
 testParser.init();
 ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
 ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
 assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneText() {
 Map<String, Object> parserConfig = new HashMap<>();
 parserConfig.put("deviceTimeZone", "America/New_York");
 Syslog5424Parser testParser = new Syslog5424Parser();
 testParser.configure(parserConfig);
 testParser.init();
 ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
 ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
 assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneText() {
  Map<String, Object> parserConfig = new HashMap<>();
  parserConfig.put("deviceTimeZone", "America/New_York");
  BasicAsaParser testParser = new BasicAsaParser();
  testParser.configure(parserConfig);
  testParser.init();
  ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
  ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
  assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneOffset() {
 Map<String, Object> parserConfig = new HashMap<>();
 parserConfig.put("deviceTimeZone", "UTC-05:00");
 Syslog3164Parser testParser = new Syslog3164Parser();
 testParser.configure(parserConfig);
 testParser.init();
 ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
 ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
 assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneText() {
 Map<String, Object> parserConfig = new HashMap<>();
 parserConfig.put("deviceTimeZone", "America/New_York");
 Syslog3164Parser testParser = new Syslog3164Parser();
 testParser.configure(parserConfig);
 testParser.init();
 ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
 ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
 assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: apache/metron

@Test
public void testConfigureTimeZoneOffset() {
  Map<String, Object> parserConfig = new HashMap<>();
  parserConfig.put("deviceTimeZone", "UTC-05:00");
  BasicAsaParser testParser = new BasicAsaParser();
  testParser.configure(parserConfig);
  testParser.init();
  ZonedDateTime deviceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), testParser.deviceClock.getZone());
  ZonedDateTime referenceTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(1475323200), ZoneOffset.ofHours(-5));
  assertTrue(deviceTime.isEqual(referenceTime));
}

代码示例来源:origin: org.apache.rya/rya.api.evaluation

@Override
  protected boolean relation(final ZonedDateTime d1, final ZonedDateTime d2) {
    Objects.requireNonNull(d1);
    Objects.requireNonNull(d2);
    return d1.isEqual(d2);
  }
}

代码示例来源:origin: org.apache.james/james-server-jmap

@Override
public boolean equals(Object other) {
  if (other == null || getClass() != other.getClass()) {
    return false;
  }
  ContinuationToken continuationToken = (ContinuationToken) other;
  return Objects.equals(username, continuationToken.username)
    && expirationDate.isEqual(continuationToken.expirationDate)
    && Objects.equals(signature, continuationToken.signature);
}

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

ZoneId zid = ZoneId.of("America/New_York");
ZoneOffset offset = ZoneOffset.from(LocalDateTime.now().atZone(zid));
ZonedDateTime zdt0 = ZonedDateTime.of(2014, 8, 24, 21, 10, 1, 777000002, offset);
ZonedDateTime zdt1 = ZonedDateTime.of(2014, 8, 24, 21, 10, 1, 777000002, zid);
System.out.println("isEqual:" + zdt0.isEqual(zdt1));
System.out.println("equals: " + zdt0.equals(zdt1));

代码示例来源:origin: org.fcrepo/modeshape-jcr

@Override
public boolean isSameAs( DateTime other ) {
  return other == this || instance.isEqual(other.toZonedDateTime());
}

代码示例来源:origin: org.apereo.cas/cas-server-core-events

@Override
public Collection<? extends CasEvent> getEventsOfType(final String type, final ZonedDateTime dateTime) {
  return getEventsOfType(type)
    .stream()
    .filter(e -> e.getCreationZonedDateTime().isEqual(dateTime) || e.getCreationZonedDateTime().isAfter(dateTime))
    .collect(Collectors.toSet());
}

代码示例来源:origin: org.apereo.cas/cas-server-core-events

@Override
public Collection<? extends CasEvent> getEventsOfTypeForPrincipal(final String type, final String principal, final ZonedDateTime dateTime) {
  return getEventsOfTypeForPrincipal(type, principal)
    .stream()
    .filter(e -> e.getCreationZonedDateTime().isEqual(dateTime) || e.getCreationZonedDateTime().isAfter(dateTime))
    .collect(Collectors.toSet());
}

代码示例来源:origin: org.apereo.cas/cas-server-core-events

@Override
public Collection<? extends CasEvent> load(final ZonedDateTime dateTime) {
  return load().stream()
    .filter(e -> e.getCreationZonedDateTime().isEqual(dateTime) || e.getCreationZonedDateTime().isAfter(dateTime))
    .collect(Collectors.toSet());
}

代码示例来源:origin: org.apereo.cas/cas-server-core-events

@Override
public Collection<? extends CasEvent> getEventsForPrincipal(final String id, final ZonedDateTime dateTime) {
  return getEventsForPrincipal(id)
    .stream()
    .filter(e -> e.getCreationZonedDateTime().isEqual(dateTime) || e.getCreationZonedDateTime().isAfter(dateTime))
    .collect(Collectors.toSet());
}

代码示例来源:origin: crawler-commons/crawler-commons

private void parseCompareDate(ZonedDateTime expected, String date, String dateFormat) {
  ZonedDateTime parsed = AbstractSiteMap.convertToZonedDateTime(date);
  if (dateFormat != null) {
    DateTimeFormatter fmt = DateTimeFormatter.ofPattern(dateFormat, Locale.ROOT).withZone(ZoneId.systemDefault());
    assertEquals("Failed to parse W3C date format:", fmt.format(expected), fmt.format(parsed));
  } else {
    assertTrue("Failed to parse W3C date format: " + expected + " <> " + parsed, expected.isEqual(parsed));
  }
}

代码示例来源:origin: crawler-commons/crawler-commons

@Test
public void testFullDateFormat() {
  // test example date with time zone offset
  // from https://www.w3.org/TR/NOTE-datetime
  // the (re)formatted date should be identical
  ZonedDateTime date1 = SiteMap.convertToZonedDateTime("1994-11-05T13:15:30Z");
  ZonedDateTime date2 = SiteMap.convertToZonedDateTime("1994-11-05T08:15:30-05:00");
  assertTrue("Failed to parse date with time zone", date1.isEqual(date2));
  String datestr1 = SiteMap.W3C_FULLDATE_FORMATTER_UTC.format(date1);
  String datestr2 = SiteMap.W3C_FULLDATE_FORMATTER_UTC.format(date2);
  assertEquals("Failed to format date", datestr1, datestr2);
}

相关文章

ZonedDateTime类方法