kotest-assertions-core / io.kotest.matchers.date / java.time.ZonedDateTime / shouldNotBeAfter

shouldNotBeAfter

infix fun ZonedDateTime.shouldNotBeAfter(date: ZonedDateTime): Unit

Asserts that this is NOT after date

Verifies that this is not after date, comparing all fields in ZonedDateTime. For example, 09/02/1998 09:00:00 -03:00 America/Sao_Paulo is not after 09/02/1998 10:00:00 -03:00 America/Sao_Paulo, and this assertion should pass for this comparison.

Opposite of ZonedDateTime.shouldBeAfter

    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 shouldNotBeAfter secondDate   // Assertion passes


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

    firstDate shouldNotBeAfter secondDate   // Assertion fails, first date IS after secondDate

See Also

ZonedDateTime.shouldBeBefore