public abstract class AbstractZonedDateTimeAssert<S extends AbstractZonedDateTimeAssert<S>> extends AbstractAssert<S,java.time.ZonedDateTime>
Modifier and Type | Field and Description |
---|---|
static String |
NULL_DATE_TIME_PARAMETER_MESSAGE |
actual, info, myself
Modifier and Type | Method and Description |
---|---|
protected java.time.ZonedDateTime |
getActual() |
S |
isAfter(String dateTimeAsString)
Same assertion as
isAfter(ZonedDateTime) but the ZonedDateTime is built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isAfter(java.time.ZonedDateTime other)
Verifies that the actual
ZonedDateTime is strictly after the given one. |
S |
isAfterOrEqualTo(String dateTimeAsString)
Same assertion as
isAfterOrEqualTo(ZonedDateTime) but the ZonedDateTime is built from given
String, which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isAfterOrEqualTo(java.time.ZonedDateTime other)
Verifies that the actual
ZonedDateTime is after or equals to the given one. |
S |
isBefore(String dateTimeAsString)
Same assertion as
isBefore(ZonedDateTime) but the ZonedDateTime is built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isBefore(java.time.ZonedDateTime other)
Verifies that the actual
ZonedDateTime is strictly before the given one. |
S |
isBeforeOrEqualTo(String dateTimeAsString)
Same assertion as
isBeforeOrEqualTo(ZonedDateTime) but the ZonedDateTime is built from given
String, which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isBeforeOrEqualTo(java.time.ZonedDateTime other)
Verifies that the actual
ZonedDateTime is before or equals to the given one. |
S |
isEqualTo(String dateTimeAsString)
Same assertion as
isEqualTo(ZonedDateTime) but the ZonedDateTime is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isEqualTo(java.time.ZonedDateTime expected)
Verifies that the actual
ZonedDateTime is equal to the given one in the actual's
ZoneId . |
S |
isEqualToIgnoringHours(java.time.ZonedDateTime other)
Verifies that actual and given
ZonedDateTime have same year, month and day fields (hour, minute, second and
nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringMinutes(java.time.ZonedDateTime other)
Verifies that actual and given
ZonedDateTime have same year, month, day and hour fields (minute, second and
nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringNanos(java.time.ZonedDateTime other)
Verifies that actual and given
ZonedDateTime have same year, month, day, hour, minute and second fields,
(nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringSeconds(java.time.ZonedDateTime other)
Verifies that actual and given
ZonedDateTime have same year, month, day, hour and minute fields (second and
nanosecond fields are ignored in comparison). |
S |
isIn(String... dateTimesAsString)
Same assertion as
isIn(ZonedDateTime...) but the ZonedDateTime are built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isIn(java.time.ZonedDateTime... expected)
Verifies that the actual
ZonedDateTime is equal to one of the given ZonedDateTime in the actual
ZonedDateTime's ZoneId . |
S |
isNotEqualTo(String dateTimeAsString)
Same assertion as
isNotEqualTo(ZonedDateTime) but the ZonedDateTime is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isNotEqualTo(java.time.ZonedDateTime expected)
Verifies that the actual value is not equal to the given one in the actual ZonedDateTime's java.time.ZoneId.
|
S |
isNotIn(String... dateTimesAsString)
Same assertion as
isNotIn(ZonedDateTime...) but the ZonedDateTime is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter) method. |
S |
isNotIn(java.time.ZonedDateTime... expected)
Verifies that the actual
ZonedDateTime is equal to one of the given ZonedDateTime in the actual
ZonedDateTime's ZoneId . |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failure, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, overridingErrorMessage, usingComparator, usingDefaultComparator, withThreadDumpOnError
public static final String NULL_DATE_TIME_PARAMETER_MESSAGE
protected java.time.ZonedDateTime getActual()
public S isBefore(java.time.ZonedDateTime other)
ZonedDateTime
is strictly before the given one.
Comparison is done on ZonedDateTime
's instant (i.e. ChronoZonedDateTime.toEpochSecond()
)
Example :
assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is not strictly before the given one.public S isBefore(String dateTimeAsString)
isBefore(ZonedDateTime)
but the ZonedDateTime
is built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check..
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01T23:59:59Z")).isBefore("2000-01-02T00:00:00Z");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not strictly before the ZonedDateTime
built
from given String.public S isBeforeOrEqualTo(java.time.ZonedDateTime other)
ZonedDateTime
is before or equals to the given one.
Comparison is done on ZonedDateTime
's instant (i.e. ChronoZonedDateTime.toEpochSecond()
)
Example :
assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59Z"))
.isBeforeOrEqualTo(parse("2000-01-02T00:00:00Z"));
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZoneDateTime
is not before or equals to the given one.public S isBeforeOrEqualTo(String dateTimeAsString)
isBeforeOrEqualTo(ZonedDateTime)
but the ZonedDateTime
is built from given
String, which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check..
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo("2000-01-01T23:59:59Z")
.isBeforeOrEqualTo("2000-01-02T00:00:00Z");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not before or equals to the ZonedDateTime
built from given String.public S isAfterOrEqualTo(java.time.ZonedDateTime other)
ZonedDateTime
is after or equals to the given one.
Comparison is done on ZonedDateTime
's instant (i.e. ChronoZonedDateTime.toEpochSecond()
)
Example :
assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z"))
.isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is not after or equals to the given one.public S isAfterOrEqualTo(String dateTimeAsString)
isAfterOrEqualTo(ZonedDateTime)
but the ZonedDateTime
is built from given
String, which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo("2000-01-01T00:00:00Z")
.isAfterOrEqualTo("1999-12-31T23:59:59Z");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not after or equals to the ZonedDateTime
built from given String.public S isAfter(java.time.ZonedDateTime other)
ZonedDateTime
is strictly after the given one.
Comparison is done on ZonedDateTime
's instant (i.e. ChronoZonedDateTime.toEpochSecond()
)
Example :
assertThat(parse("2000-01-01T00:00:00Z")).isAfter(parse("1999-12-31T23:59:59Z"));
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is not strictly after the given one.public S isAfter(String dateTimeAsString)
isAfter(ZonedDateTime)
but the ZonedDateTime
is built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T00:00:00Z")).isAfter("1999-12-31T23:59:59Z");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not strictly after the ZonedDateTime
built
from given String.public S isEqualToIgnoringNanos(java.time.ZonedDateTime other)
ZonedDateTime
have same year, month, day, hour, minute and second fields,
(nanosecond fields are ignored in comparison).
Note that given ZonedDateTime
is converted in the actual's ZoneId
before comparison.
Assertion can fail with dateTimes in same chronological nanosecond time window, e.g :
2000-01-01T00:00:01.000000000 and 2000-01-01T00:00:00.999999999.
Assertion fails as second fields differ even if time difference is only 1ns.
Code example :
// successfull assertions
ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 0);
ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 456);
assertThat(dateTime1).isEqualToIgnoringNanos(dateTime2);
// failing assertions (even if time difference is only 1ms)
ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 0, 0, 1, 0);
ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 0, 0, 0, 999999999);
assertThat(dateTimeA).isEqualToIgnoringNanos(dateTimeB);
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is are not equal with nanoseconds ignored.public S isEqualToIgnoringSeconds(java.time.ZonedDateTime other)
ZonedDateTime
have same year, month, day, hour and minute fields (second and
nanosecond fields are ignored in comparison).
Note that given ZonedDateTime
is converted in the actual's ZoneId
before comparison.
Assertion can fail with ZonedDateTimes in same chronological second time window, e.g :
2000-01-01T00:01:00.000 and 2000-01-01T00:00:59.000.
Assertion fails as minute fields differ even if time difference is only 1ns.
Code example :
// successfull assertions
ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 50, 0, 0);
ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 23, 50, 10, 456);
assertThat(dateTime1).isEqualToIgnoringSeconds(dateTime2);
// failing assertions (even if time difference is only 1ns)
ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 23, 50, 00, 0);
ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 23, 49, 59, 999999999);
assertThat(dateTimeA).isEqualToIgnoringSeconds(dateTimeB);
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is are not equal with second and nanosecond fields
ignored.public S isEqualToIgnoringMinutes(java.time.ZonedDateTime other)
ZonedDateTime
have same year, month, day and hour fields (minute, second and
nanosecond fields are ignored in comparison).
Note that given ZonedDateTime
is converted in the actual's ZoneId
before comparison.
Assertion can fail with dateTimes in same chronological second time window, e.g :
2000-01-01T01:00:00.000 and 2000-01-01T00:59:59.000.
Time difference is only 1s but hour fields differ.
Code example :
// successfull assertions
ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 50, 0, 0);
ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 23, 00, 2, 7);
assertThat(dateTime1).isEqualToIgnoringMinutes(dateTime2);
// failing assertions (even if time difference is only 1ms)
ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 1, 01, 00, 00, 000);
ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 00, 59, 59, 999);
assertThat(dateTimeA).isEqualToIgnoringMinutes(dateTimeB);
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is are not equal ignoring minute, second and nanosecond
fields.public S isEqualToIgnoringHours(java.time.ZonedDateTime other)
ZonedDateTime
have same year, month and day fields (hour, minute, second and
nanosecond fields are ignored in comparison).
Note that given ZonedDateTime
is converted in the actual's ZoneId
before comparison.
Assertion can fail with dateTimes in same chronological minute time window, e.g :
2000-01-01T23:59:00.000 and 2000-01-02T00:00:00.000.
Time difference is only 1min but day fields differ.
Code example :
// successfull assertions
ZonedDateTime dateTime1 = ZonedDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneId.systemDefault());
ZonedDateTime dateTime2 = ZonedDateTime.of(2000, 1, 1, 00, 00, 00, 000, ZoneId.systemDefault());
assertThat(dateTime1).isEqualToIgnoringHours(dateTime2);
// failing assertions (even if time difference is only 1ms)
ZonedDateTime dateTimeA = ZonedDateTime.of(2000, 1, 2, 00, 00, 00, 000, ZoneId.systemDefault());
ZonedDateTime dateTimeB = ZonedDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneId.systemDefault());
assertThat(dateTimeA).isEqualToIgnoringHours(dateTimeB);
other
- the given ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if other ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is are not equal with second and nanosecond fields
ignored.public S isEqualTo(java.time.ZonedDateTime expected)
ZonedDateTime
is equal to the given one in the actual's
ZoneId
.
Example :
ZonedDateTime firstOfJanuary2000InUTC = ZonedDateTime.parse("2000-01-01T00:00:00Z");
assertThat(firstOfJanuary2000InUTC).isEqualTo(parse("2000-01-01T00:00:00Z"));
// the following assertion succeeds as ZonedDateTime are compared in actual's time zone
// 2000-01-01T01:00:00+01:00 = 2000-01-01T00:00:00 in UTC
assertThat(firstOfJanuary2000InUTC).isEqualTo(parse("2000-01-01T01:00:00+01:00"));
expected
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual ZonedDateTime
is not equal to the ZonedDateTime
in the actual
ZonedDateTime's java.time.ZoneId.public S isEqualTo(String dateTimeAsString)
isEqualTo(ZonedDateTime)
but the ZonedDateTime
is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
ZonedDateTime firstOfJanuary2000InUTC = ZonedDateTime.parse("2000-01-01T00:00:00Z");
assertThat(firstOfJanuary2000InUTC).isEqualTo("2000-01-01T00:00:00Z");
// the following assertion succeeds as ZonedDateTime are compared in actual's time zone
// 2000-01-01T01:00:00+01:00 = 2000-01-01T00:00:00 in UTC
assertThat(firstOfJanuary2000InUTC).isEqualTo("2000-01-01T01:00:00+01:00");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not equal to the ZonedDateTime
built from
given String.public S isNotEqualTo(java.time.ZonedDateTime expected)
Example :
assertThat(parse("2000-01-01T00:00:00Z")).isNotEqualTo(parse("2000-01-15T00:00:00Z"));
expected
- the given value to compare the actual value to.this
assertion object.AssertionError
- if the actual ZonedDateTime
is equal to the ZonedDateTime
in the actual
ZonedDateTime's java.time.ZoneId.public S isNotEqualTo(String dateTimeAsString)
isNotEqualTo(ZonedDateTime)
but the ZonedDateTime
is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
created from the given String is built in the ZoneId
of the
ZonedDateTime
to check.. ZonedDateTime
.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01T00:00:00Z")).isNotEqualTo("2000-01-15T00:00:00Z");
dateTimeAsString
- String representing a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is equal to the ZonedDateTime
built from given
String.public S isIn(java.time.ZonedDateTime... expected)
ZonedDateTime
is equal to one of the given ZonedDateTime
in the actual
ZonedDateTime's ZoneId
.
Example :
assertThat(parse("2000-01-01T00:00:00Z")).isIn(parse("1999-12-31T23:59:59Z"),
parse("2000-01-01T00:00:00Z"));
expected
- the given ZonedDateTime
s to compare the actual value to.this
assertion object.AssertionError
- if the actual ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is not in the given ZonedDateTime
s.public S isIn(String... dateTimesAsString)
isIn(ZonedDateTime...)
but the ZonedDateTime
are built from given String, which
must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
s created from the given Strings are built in the ZoneId
of
the ZonedDateTime
to check..
Example :
// use String based representation of LocalDateTime
assertThat(parse("2000-01-01T00:00:00Z")).isIn("1999-12-31T23:59:59Z",
"2000-01-01T00:00:00Z");
dateTimesAsString
- String array representing ZonedDateTime
s.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not in the ZonedDateTime
s built from given
Strings.public S isNotIn(java.time.ZonedDateTime... expected)
ZonedDateTime
is equal to one of the given ZonedDateTime
in the actual
ZonedDateTime's ZoneId
.
Example :
assertThat(parse("2000-01-01T00:00:00Z")).isNotIn(parse("1999-12-31T23:59:59Z"),
parse("2000-01-02T00:00:00Z"));
expected
- the given ZonedDateTime
s to compare the actual value to.this
assertion object.AssertionError
- if the actual ZonedDateTime
is null
.AssertionError
- if the actual ZonedDateTime
is not in the given ZonedDateTime
s.public S isNotIn(String... dateTimesAsString)
isNotIn(ZonedDateTime...)
but the ZonedDateTime
is built from given String,
which must follow ISO date-time format to allow calling ZonedDateTime.parse(CharSequence, DateTimeFormatter)
method.
Note that the ZonedDateTime
s created from the given Strings are built in the ZoneId
of
the ZonedDateTime
to check..
Example :
// use String based representation of ZonedDateTime
assertThat(parse("2000-01-01T00:00:00Z")).isNotIn("1999-12-31T23:59:59Z",
"2000-01-02T00:00:00Z");
dateTimesAsString
- String array representing ZonedDateTime
s.AssertionError
- if the actual ZonedDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a ZonedDateTime
.AssertionError
- if the actual ZonedDateTime
is not equal to the ZonedDateTime
built from
given String.Copyright © 2014-2015 AssertJ. All Rights Reserved.