Top Description Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractLocalDateTimeAssert<SELF extends AbstractLocalDateTimeAssert<SELF>>

extends AbstractTemporalAssert<SELF extends AbstractLocalDateTimeAssert<SELF>, LocalDateTime>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.LocalDateTimeAssert
Type Parameters
<SELF>
the "self" type of this assertion class.
Static Imports
java.time.Clock.systemUTC, .LocalDateTime.now, org.assertj.core.error.ShouldBeEqualIgnoringHours.shouldBeEqualIgnoringHours, .ShouldBeEqualIgnoringMinutes.shouldBeEqualIgnoringMinutes, .ShouldBeEqualIgnoringNanos.shouldBeEqualIgnoringNanos, .ShouldBeEqualIgnoringSeconds.shouldBeEqualIgnoringSeconds, .ShouldBeInTheFuture.shouldBeInTheFuture, .ShouldBeInThePast.shouldBeInThePast, .ShouldHaveDateField.shouldHaveDateField, .ShouldHaveDateField.shouldHaveMonth, org.assertj.core.util.Preconditions.checkArgument

Assertions for LocalDateTime type from new Date & Time API introduced in Java 8.
Authors
Paweł Stawicki, Joel Costigliola, Marcin Zajączkowski, Nikolaos Georgiou

Field Summary

Modifier and TypeField and Description
public static final String
Inherited from org.assertj.core.api.AbstractTemporalAssert:
comparables

Constructor Summary

AccessConstructor and Description
protected
AbstractLocalDateTimeAssert(LocalDateTime
the actual value to verify
actual
,
Class<?>
the "self type"
selfType
)

Creates a new org.assertj.core.api.AbstractLocalDateTimeAssert.

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true if both datetime are in the same year, month, day of month and hour, false otherwise.
areEqualIgnoringMinutes
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year, month, day of month and hour, false otherwise.

private static boolean

Returns:

true if both datetime are in the same year, month and day of month, hour, minute and second, false otherwise.
areEqualIgnoringNanos
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year, month and day of month, hour, minute and second, false otherwise.

private static boolean

Returns:

true if both datetime are in the same year, month, day of month, hour and minute, false otherwise.
areEqualIgnoringSeconds
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year, month, day of month, hour and minute, false otherwise.

private static void
assertLocalDateTimeAsStringParameterIsNotNull(String
String representing the LocalDateTime to compare actual with
localDateTimeAsString
)

Check that the LocalDateTime string representation to compare actual LocalDateTime to is not null, otherwise throws a IllegalArgumentException with an explicit message

private static void
assertLocalDateTimeParameterIsNotNull(LocalDateTime
the LocalDateTime to check
other
)

Check that the LocalDateTime to compare actual LocalDateTime to is not null, in that case throws a IllegalArgumentException with an explicit message

private Comparables
private void
private static Object[]
convertToLocalDateTimeArray(String... dateTimesAsString)

public SELF

Returns:

this assertion object.
hasDayOfMonth
(int
the given numeric day.
dayOfMonth
)

Verifies that actual LocalDateTime is in the given day of month.

public SELF

Returns:

this assertion object.
hasHour
(int
the given hour.
hour
)

Verifies that actual LocalDateTime is in the given hour.

public SELF

Returns:

this assertion object.
hasMinute
(int
the given minute.
minute
)

Verifies that actual LocalDateTime is in the given minute.

public SELF

Returns:

this assertion object.
hasMonth
(Month
the given Month.
month
)

Verifies that actual LocalDateTime is in the given Month.

public SELF

Returns:

this assertion object.
hasMonthValue
(int
the given month value between 1 and 12 inclusive.
monthVal
)

Verifies that actual LocalDateTime has same month value.

public SELF

Returns:

this assertion object.
hasNano
(int
the given second.
nano
)

Verifies that actual LocalDateTime is in the given nanosecond.

public SELF

Returns:

this assertion object.
hasSecond
(int
the given second.
second
)

Verifies that actual LocalDateTime is in the given second.

public SELF

Returns:

this assertion object.
hasYear
(int
the given year.
year
)

Verifies that actual LocalDateTime is in the given year.

private static boolean

Returns:

true if both datetime are in the same year, false otherwise
haveSameYear
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year, false otherwise.

private static boolean

Returns:

true if both datetime are in the same year and month, false otherwise
haveSameYearAndMonth
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year and month, false otherwise.

private static boolean

Returns:

true if both datetime are in the same year, month and day of month, false otherwise
haveSameYearMonthAndDayOfMonth
(LocalDateTime
the actual datetime. expected not be null
actual
,
LocalDateTime
the other datetime. expected not be null
other
)

Returns true if both datetime are in the same year, month and day of month, false otherwise.

public SELF

Returns:

this assertion object.
isAfter
(LocalDateTime
the given LocalDateTime.
other
)

Verifies that the actual LocalDateTime is strictly after the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isAfter(ChronoLocalDateTime).

public SELF

Returns:

this assertion object.
isAfter
(String
String representing a LocalDateTime.
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.

public SELF

Returns:

this assertion object.
isAfterOrEqualTo
(LocalDateTime
the given LocalDateTime.
other
)

Verifies that the actual LocalDateTime is after or equals to the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isAfter(ChronoLocalDateTime).

public SELF

Returns:

this assertion object.
isAfterOrEqualTo
(String
String representing a LocalDateTime.
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.

public SELF

Returns:

this assertion object.
isBefore
(LocalDateTime
the given LocalDateTime.
other
)

Verifies that the actual LocalDateTime is strictly before the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isBefore(ChronoLocalDateTime).

public SELF

Returns:

this assertion object.
isBefore
(String
String representing a LocalDateTime.
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.

public SELF

Returns:

this assertion object.
isBeforeOrEqualTo
(LocalDateTime
the given LocalDateTime.
other
)

Verifies that the actual LocalDateTime is before or equals to the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isBefore(ChronoLocalDateTime).

public SELF

Returns:

this assertion object.
isBeforeOrEqualTo
(String
String representing a LocalDateTime.
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.

public SELF

Returns:

this assertion object.
isBetween
(LocalDateTime
the start value (inclusive), expected not to be null.
startInclusive
,
LocalDateTime
the end value (inclusive), expected not to be null.
endInclusive
)

Verifies that the actual LocalDateTime is in the [start, end] period (start and end included) according to the ChronoLocalDateTime#timeLineOrder() comparator.

public SELF

Returns:

this assertion object.
isBetween
(String
the start value (inclusive), expected not to be null.
startInclusive
,
String
the end value (inclusive), expected not to be null.
endInclusive
)

Same assertion as isBetween(LocalDateTime, LocalDateTime) but here you pass LocalDateTime String representations which must follow ISO LocalDateTime format to allow calling LocalDateTime#parse(CharSequence) method.

public SELF

Returns:

this assertion object
isCloseTo
(LocalDateTime
the localDateTime to compare actual to
other
,
TemporalOffset<? super LocalDateTime>
the offset used for comparison
offset
)

Overrides org.assertj.core.api.AbstractTemporalAssert.isCloseTo.

Verifies that the actual LocalDateTime is close to the other according to the given TemporalOffset.
public SELF

Returns:

this assertion object
isCloseToUtcNow
(TemporalUnitOffset
The offset used for comparison
offset
)

Verifies that the actual LocalDateTime is close to the current date and time on the UTC timezone, according to the given TemporalUnitOffset.

public SELF

Returns:

this assertion object.
isEqualTo
(Object
the given LocalDateTime.
other
)

Overrides org.assertj.core.api.AbstractAssert.isEqualTo.

Implements org.assertj.core.api.Assert.isEqualTo.

Verifies that the actual LocalDateTime is equal to the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isEqual(ChronoLocalDateTime).
public SELF

Returns:

this assertion object.
isEqualTo
(String
String representing a LocalDateTime.
dateTimeAsString
)

Same assertion as 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.

public SELF

Returns:

this assertion object.
isEqualToIgnoringHours
(LocalDateTime
the given LocalDateTime.
other
)

Deprecated Use isCloseTo(LocalDateTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.
Verifies that actual and given LocalDateTime have same year, month and day fields (hour, minute, second and nanosecond fields are ignored in comparison).
public SELF

Returns:

this assertion object.
isEqualToIgnoringMinutes
(LocalDateTime
the given LocalDateTime.
other
)

Deprecated Use isCloseTo(LocalDateTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.
Verifies that actual and given LocalDateTime have same year, month, day and hour fields (minute, second and nanosecond fields are ignored in comparison).
public SELF

Returns:

this assertion object.
isEqualToIgnoringNanos
(LocalDateTime
the given LocalDateTime.
other
)

Verifies that actual and given LocalDateTime have same year, month, day, hour, minute and second fields, (nanosecond fields are ignored in comparison).

public SELF

Returns:

this assertion object.
isEqualToIgnoringSeconds
(LocalDateTime
the given LocalDateTime.
other
)

Deprecated Use isCloseTo(LocalDateTime, TemporalOffset) instead, although not exactly the same semantics, this is the right way to compare with a given precision.
Verifies that actual and given LocalDateTime have same year, month, day, hour and minute fields (second and nanosecond fields are ignored in comparison).
public SELF

Returns:

this assertion object.
isIn
(String...
String array representing LocalDateTimes.
dateTimesAsString
)

Same assertion as 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.

public SELF

Returns:

this assertion object.
isInTheFuture
()

Verifies that the actual LocalDateTime is strictly in the future.

public SELF

Returns:

this assertion object.
isInThePast
()

Verifies that the actual LocalDateTime is strictly in the past.

public SELF

Returns:

this assertion object.
isNotEqualTo
(Object
the given value to compare the actual value to.
other
)

Overrides org.assertj.core.api.AbstractAssert.isNotEqualTo.

Implements org.assertj.core.api.Assert.isNotEqualTo.

Verifies that the actual LocalDateTime is not equal to the given one according to the ChronoLocalDateTime#timeLineOrder() comparator which is consistent with LocalDateTime#isEqual(ChronoLocalDateTime).
public SELF

Returns:

this assertion object.
isNotEqualTo
(String
String representing a LocalDateTime.
dateTimeAsString
)

Same assertion as 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.

public SELF

Returns:

this assertion object.
isNotIn
(String...
Array of String representing a LocalDateTime.
dateTimesAsString
)

Same assertion as 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.

public SELF

Returns:

this assertion object.
isStrictlyBetween
(LocalDateTime
the start value (exclusive), expected not to be null.
startExclusive
,
LocalDateTime
the end value (exclusive), expected not to be null.
endExclusive
)

Verifies that the actual LocalDateTime is in the ]start, end[ period (start and end excluded) according to the ChronoLocalDateTime#timeLineOrder() comparator.

public SELF

Returns:

this assertion object.
isStrictlyBetween
(String
the start value (exclusive), expected not to be null.
startExclusive
,
String
the end value (exclusive), expected not to be null.
endExclusive
)

Same assertion as isStrictlyBetween(LocalDateTime, LocalDateTime) but here you pass LocalDateTime String representations which must follow ISO LocalDateTime format to allow calling LocalDateTime#parse(CharSequence) method.

protected LocalDateTime
parse(String
the string to parse, not null
localDateTimeAsString
)

Implements abstract org.assertj.core.api.AbstractTemporalAssert.parse.

Obtains an instance of TEMPORAL from a string representation in ISO date format.
public SELF
usingDefaultComparator()

Overrides org.assertj.core.api.AbstractTemporalAssert.usingDefaultComparator.

Implements org.assertj.core.api.Assert.usingDefaultComparator.

Revert to standard comparison for the incoming assertion checks.
Inherited from org.assertj.core.api.AbstractTemporalAssert:
getActualisCloseTousingComparatorusingComparator