kotest-assertions-core / io.kotest.matchers.date / after

after

fun after(anotherInstant: Instant): Matcher<Instant> fun after(time: LocalTime): Matcher<LocalTime>

Matcher that compares two LocalTimes and checks whether one is after the other

Verifies that two LocalTimes occurs in a certain order, checking that one happened after the other. For example, 12:30:59:2222 is after 12:30:59:1111, and the matcher will have a positive result for this comparison

    val firstTime = LocalTime.of(12:30:59:2222)
    val secondTime = LocalTime.of(09:30:59:2222)

    firstTime shouldBe after(secondTime ) // Assertion passes


    val firstTime = LocalTime.of(12:30:59:2222)
    val secondTime = LocalTime.of(16:30:59:2222)

    firstTime shouldNotBe after(secondTime)   // Assertion passes

See Also

LocalTime.shouldBeAfter

LocalTime.shouldNotBeAfter

fun after(date: LocalDate): Matcher<LocalDate>

Matcher that compares two LocalDates and checks whether one is after the other

Verifies that two LocalDates occurs in a certain order, checking that one happened after the other. For example, 10/02/1998 is after 09/02/1998, and the matcher will have a positive result for this comparison

    val firstDate = LocalDate.of(1998, 2, 9)
    val secondDate = LocalDate.of(1998, 2, 8)

    firstDate shouldBe after(secondDate ) // Assertion passes


    val firstDate = LocalDate.of(1998, 2, 9)
    val secondDate = LocalDate.of(1998, 2, 10)

    firstDate shouldNotBe after(secondDate)   // Assertion passes

See Also

LocalDate.shouldBeAfter

LocalDate.shouldNotBeAfter

fun after(date: LocalDateTime): Matcher<LocalDateTime>

Matcher that compares two LocalDateTimes and checks whether one is after the other

Verifies that two LocalDateTimes occurs in a certain order, checking that one happened after the other. For example, 09/02/1998 10:00:00 is after 09/02/1998 09:00:00, and the matcher will have a positive result for this comparison

    val firstDate = LocalDateTime.of(1998, 2, 9, 10, 0, 0)
    val secondDate = LocalDateTime.of(1998, 2, 8, 10, 0, 0)

    firstDate shouldBe after(secondDate ) // Assertion passes


    val firstDate = LocalDateTime.of(1998, 2, 9, 10, 0, 0)
    val secondDate = LocalDateTime.of(1998, 2, 10, 10, 0, 0)

    firstDate shouldNotBe after(secondDate)   // Assertion passes

See Also

LocalDateTime.shouldBeAfter

LocalDateTime.shouldNotBeAfter

fun after(date: ZonedDateTime): Matcher<ZonedDateTime>

Matcher that compares two ZonedDateTimes and checks whether one is after the other

Verifies that two ZonedDateTimes occurs in a certain order, checking that one happened after the other. For example, 09/02/1998 10:00:00 -03:00 America/Sao_Paulo is after 09/02/1998 09:00:00 -03:00 America/Sao_Paulo, and the matcher will have a positive result for this comparison

    val firstDate = ZonedDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
    val secondDate = ZonedDateTime.of(1998, 2, 8, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))

    firstDate shouldBe after(secondDate ) // Assertion passes


    val firstDate = ZonedDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
    val secondDate = ZonedDateTime.of(1998, 2, 10, 10, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))

    firstDate shouldNotBe after(secondDate)   // Assertion passes

See Also

ZonedDateTime.shouldBeAfter

ZonedDateTime.shouldNotBeAfter

fun after(date: OffsetDateTime): Matcher<OffsetDateTime>

Matcher that compares two OffsetDateTimes and checks whether one is after the other

Verifies that two OffsetDateTimes occurs in a certain order, checking that one happened after the other. For example, 09/02/1998 10:00:00 -03:00 is after 09/02/1998 09:00:00 -03:00, and the matcher will have a positive result for this comparison

    val firstDate = OffsetDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneOffset.ofHours(-3))
    val secondDate = OffsetDateTime.of(1998, 2, 8, 10, 0, 0, 0, ZoneOffset.ofHours(-3))

    firstDate shouldBe after(secondDate ) // Assertion passes


    val firstDate = OffsetDateTime.of(1998, 2, 9, 10, 0, 0, 0, ZoneOffset.ofHours(-3))
    val secondDate = OffsetDateTime.of(1998, 2, 10, 10, 0, 0, 0, ZoneOffset.ofHours(-3))

    firstDate shouldNotBe after(secondDate)   // Assertion passes

See Also

OffsetDateTime.shouldBeAfter

OffsetDateTime.shouldNotBeAfter