public abstract class AbstractLocalDateTimeAssert<S extends AbstractLocalDateTimeAssert<S>> extends AbstractAssert<S,java.time.LocalDateTime>
LocalDateTime
type from new Date & Time API introduced in Java 8.Modifier and Type | Field and Description |
---|---|
static String |
NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE |
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractLocalDateTimeAssert(java.time.LocalDateTime actual,
Class<?> selfType)
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
protected java.time.LocalDateTime |
getActual() |
S |
isAfter(java.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is strictly after the given one. |
S |
isAfter(String localDateTimeAsString)
Same assertion as
isAfter(LocalDateTime) but the LocalDateTime is built from given a String that
must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isAfterOrEqualTo(java.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is after or equals to the given one. |
S |
isAfterOrEqualTo(String localDateTimeAsString)
Same assertion as
isAfterOrEqualTo(LocalDateTime) but the LocalDateTime is built from given
String, which must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isBefore(java.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is strictly before the given one. |
S |
isBefore(String localDateTimeAsString)
Same assertion as
isBefore(LocalDateTime) but the LocalDateTime is built from given String, which
must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isBeforeOrEqualTo(java.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is before or equals to the given one. |
S |
isBeforeOrEqualTo(String localDateTimeAsString)
Same assertion as
isBeforeOrEqualTo(LocalDateTime) but the LocalDateTime is built from given
String, which must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isEqualTo(String dateTimeAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be LocalDateTime ) but here you
pass LocalDateTime String representation that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isEqualToIgnoringHours(java.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month and day fields (hour, minute, second and
nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringMinutes(java.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day and hour fields (minute, second and
nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringNanos(java.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day, hour, minute and second fields,
(nanosecond fields are ignored in comparison). |
S |
isEqualToIgnoringSeconds(java.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day, hour and minute fields (second and
nanosecond fields are ignored in comparison). |
S |
isIn(String... dateTimesAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be LocalDateTime ) but here you
pass LocalDateTime String representations that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isNotEqualTo(String dateTimeAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be LocalDateTime ) but here you
pass LocalDateTime String representation that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
S |
isNotIn(String... dateTimesAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be LocalDateTime ) but here you
pass LocalDateTime String representations that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence) method. |
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_LOCAL_DATE_TIME_PARAMETER_MESSAGE
protected AbstractLocalDateTimeAssert(java.time.LocalDateTime actual, Class<?> selfType)
AbstractLocalDateTimeAssert
.selfType
- the "self type"actual
- the actual value to verifyprotected java.time.LocalDateTime getActual()
public S isBefore(java.time.LocalDateTime other)
LocalDateTime
is strictly before the given one.
Example :
assertThat(parse("2000-01-01T23:59:59")).isBefore(parse("2000-01-02T00:00:00"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not strictly before the given one.public S isBefore(String localDateTimeAsString)
isBefore(LocalDateTime)
but the LocalDateTime
is built from given String, which
must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01T23:59:59")).isBefore("2000-01-02T00:00:00");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not strictly before the LocalDateTime
built
from given String.public S isBeforeOrEqualTo(java.time.LocalDateTime other)
LocalDateTime
is before or equals to the given one.
Example :
assertThat(parse("2000-01-01T23:59:59")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59"))
.isBeforeOrEqualTo(parse("2000-01-02T00:00:00"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not before or equals to the given one.public S isBeforeOrEqualTo(String localDateTimeAsString)
isBeforeOrEqualTo(LocalDateTime)
but the LocalDateTime
is built from given
String, which must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T23:59:59")).isBeforeOrEqualTo("2000-01-01T23:59:59")
.isBeforeOrEqualTo("2000-01-02T00:00:00");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not before or equals to the LocalDateTime
built from given String.public S isAfterOrEqualTo(java.time.LocalDateTime other)
LocalDateTime
is after or equals to the given one.
Example :
assertThat(parse("2000-01-01T00:00:00")).isAfterOrEqualTo(parse("2000-01-01T00:00:00"))
.isAfterOrEqualTo(parse("1999-12-31T23:59:59"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not after or equals to the given one.public S isAfterOrEqualTo(String localDateTimeAsString)
isAfterOrEqualTo(LocalDateTime)
but the LocalDateTime
is built from given
String, which must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T00:00:00")).isAfterOrEqualTo("2000-01-01T00:00:00")
.isAfterOrEqualTo("1999-12-31T23:59:59");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not after or equals to the LocalDateTime
built from given String.public S isAfter(java.time.LocalDateTime other)
LocalDateTime
is strictly after the given one.
Example :
assertThat(parse("2000-01-01T00:00:00")).isAfter(parse("1999-12-31T23:59:59"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not strictly after the given one.public S isAfter(String localDateTimeAsString)
isAfter(LocalDateTime)
but the LocalDateTime
is built from given a String that
must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01T00:00:00")).isAfter("1999-12-31T23:59:59");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not strictly after the LocalDateTime
built
from given String.public S isEqualTo(String dateTimeAsString)
AbstractAssert.isEqualTo(Object)
(where Object is expected to be LocalDateTime
) but here you
pass LocalDateTime
String representation that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01T00:00:00")).isEqualTo("2000-01-01T00:00:00");
dateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not equal to the LocalDateTime
built from
given String.public S isNotEqualTo(String dateTimeAsString)
AbstractAssert.isNotEqualTo(Object)
(where Object is expected to be LocalDateTime
) but here you
pass LocalDateTime
String representation that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01T00:00:00")).isNotEqualTo("2000-01-15T00:00:00");
dateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is equal to the LocalDateTime
built from given
String.public S isIn(String... dateTimesAsString)
AbstractAssert.isIn(Object...)
(where Objects are expected to be LocalDateTime
) but here you
pass LocalDateTime
String representations that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use String based representation of LocalDateTime
assertThat(parse("2000-01-01T00:00:00")).isIn("1999-12-31T00:00:00", "2000-01-01T00:00:00");
dateTimesAsString
- String array representing LocalDateTime
s.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not in the LocalDateTime
s built from given
Strings.public S isNotIn(String... dateTimesAsString)
AbstractAssert.isNotIn(Object...)
(where Objects are expected to be LocalDateTime
) but here you
pass LocalDateTime
String representations that must follow ISO LocalDateTime format to allow calling LocalDateTime.parse(CharSequence)
method.
Example :
// use String based representation of LocalDateTime
assertThat(parse("2000-01-01T00:00:00")).isNotIn("1999-12-31T00:00:00", "2000-01-02T00:00:00");
dateTimesAsString
- Array of String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is in the LocalDateTime
s built from given
Strings.public S isEqualToIgnoringNanos(java.time.LocalDateTime other)
LocalDateTime
have same year, month, day, hour, minute and second fields,
(nanosecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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
LocalDateTime localDateTime1 = LocalDateTime.of(2000, 1, 1, 0, 0, 1, 0);
LocalDateTime localDateTime2 = LocalDateTime.of(2000, 1, 1, 0, 0, 1, 456);
assertThat(localDateTime1).isEqualToIgnoringNanos(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = LocalDateTime.of(2000, 1, 1, 0, 0, 1, 0);
LocalDateTime localDateTimeB = LocalDateTime.of(2000, 1, 1, 0, 0, 0, 999999999);
assertThat(localDateTimeA).isEqualToIgnoringNanos(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with nanoseconds ignored.public S isEqualToIgnoringSeconds(java.time.LocalDateTime other)
LocalDateTime
have same year, month, day, hour and minute fields (second and
nanosecond fields are ignored in comparison).
Assertion can fail with LocalDateTimes 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 1s.
Code example :
// successful assertions
LocalDateTime localDateTime1 = LocalDateTime.of(2000, 1, 1, 23, 50, 0, 0);
LocalDateTime localDateTime2 = LocalDateTime.of(2000, 1, 1, 23, 50, 10, 456);
assertThat(localDateTime1).isEqualToIgnoringSeconds(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = LocalDateTime.of(2000, 1, 1, 23, 50, 00, 000);
LocalDateTime localDateTimeB = LocalDateTime.of(2000, 1, 1, 23, 49, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringSeconds(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with second and nanosecond fields
ignored.public S isEqualToIgnoringMinutes(java.time.LocalDateTime other)
LocalDateTime
have same year, month, day and hour fields (minute, second and
nanosecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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 :
// successful assertions
LocalDateTime localDateTime1 = LocalDateTime.of(2000, 1, 1, 23, 50, 0, 0);
LocalDateTime localDateTime2 = LocalDateTime.of(2000, 1, 1, 23, 00, 2, 7);
assertThat(localDateTime1).isEqualToIgnoringMinutes(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = LocalDateTime.of(2000, 1, 1, 01, 00, 00, 000);
LocalDateTime localDateTimeB = LocalDateTime.of(2000, 1, 1, 00, 59, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringMinutes(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal ignoring minute, second and nanosecond
fields.public S isEqualToIgnoringHours(java.time.LocalDateTime other)
LocalDateTime
have same year, month and day fields (hour, minute, second and
nanosecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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
LocalDateTime localDateTime1 = LocalDateTime.of(2000, 1, 1, 23, 59, 59, 999);
LocalDateTime localDateTime2 = LocalDateTime.of(2000, 1, 1, 00, 00, 00, 000);
assertThat(localDateTime1).isEqualToIgnoringHours(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = LocalDateTime.of(2000, 1, 2, 00, 00, 00, 000);
LocalDateTime localDateTimeB = LocalDateTime.of(2000, 1, 1, 23, 59, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringHours(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with second and nanosecond fields
ignored.Copyright © 2014-2015 AssertJ. All Rights Reserved.