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

shouldBeAfter

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

Asserts that this is after date

Verifies that this is after date, comparing all fields in ZonedDateTime. 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 this assertion should pass for this comparison.

Opposite of ZonedDateTime.shouldNotBeAfter

    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 shouldBeAfter 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 shouldBeAfter secondDate  // Assertion fails, firstDate is NOT after secondDate

See Also

ZonedDateTime.shouldNotBeBefore