fun ZonedDateTime.shouldBeBetween(a: ZonedDateTime, b: ZonedDateTime): Unit
Asserts that this is between a and b
Verifies that this is after a and before b, comparing all fields in ZonedDateTime.
Opposite of ZonedDateTime.shouldNotBeBetween
val date = ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val firstDate = ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val secondDate = ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
date.shouldBeBetween(firstDate, secondDate) // Assertion passes
val date = ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val firstDate = ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
val secondDate = ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo"))
date.shouldBeBetween(firstDate, secondDate) // Assertion fails, date is NOT between firstDate and secondDate
See Also