@Test public void shouldCompareInUtc() { matcher = new ZonedDateTimeEqualsInUtcMatcher(ZonedDateTime.parse("2020-04-17T08:06:03+02:00")); assertThat(matcher.matches(ZonedDateTime.parse("2020-04-17T06:06:03Z"))).isTrue(); assertThat(matcher.matches(ZonedDateTime.parse("2020-04-17T09:06:03+03:00"))).isTrue(); assertThat(new ZonedDateTimeEqualsInUtcMatcher(null).matches(null)).isTrue(); }
@Override public boolean matches(Object item) { ZonedDateTime actualWithZone = item == null ? null : ZonedDateTime.parse(String.valueOf(item)); LocalDateTime actual = toUtcLocal(actualWithZone); return Objects.equals(actual, expected); }
ZonedDateTimeEqualsInUtcMatcher extends BaseMatcher<ZonedDateTime> { @Override public boolean matches(Object item) { ZonedDateTime actualWithZone = item == null ? null : ZonedDateTime.parse(String.valueOf(item)); LocalDateTime actual = toUtcLocal(actualWithZone); return Objects.equals(actual, expected); } }
ZonedDateTimeEqualsInUtcMatcher extends BaseMatcher<ZonedDateTime> { @Override public boolean matches(Object item) { ZonedDateTime actualWithZone = item == null ? null : ZonedDateTime.parse(String.valueOf(item)); LocalDateTime actual = toUtcLocal(actualWithZone); return Objects.equals(actual, expected); } ZonedDateTimeEqualsInUtcMatcher(ZonedDateTime expected); }
ZonedDateTimeEqualsInUtcMatcher extends BaseMatcher<ZonedDateTime> { @Override public boolean matches(Object item) { ZonedDateTime actualWithZone = item == null ? null : ZonedDateTime.parse(String.valueOf(item)); LocalDateTime actual = toUtcLocal(actualWithZone); return Objects.equals(actual, expected); } ZonedDateTimeEqualsInUtcMatcher(ZonedDateTime expected); @Override boolean matches(Object item); @Override void describeTo(Description description); static Matcher<ZonedDateTime> zonedDateTimeEquals(ZonedDateTime expected); }
ZonedDateTimeEqualsInUtcMatcher extends BaseMatcher<ZonedDateTime> { @Override public boolean matches(Object item) { ZonedDateTime actualWithZone = item == null ? null : ZonedDateTime.parse(String.valueOf(item)); LocalDateTime actual = toUtcLocal(actualWithZone); return Objects.equals(actual, expected); } ZonedDateTimeEqualsInUtcMatcher(ZonedDateTime expected); @Override boolean matches(Object item); @Override void describeTo(Description description); static Matcher<ZonedDateTime> zonedDateTimeEquals(ZonedDateTime expected);  }