using <, >, and == is not always the same as using .isBefore, .isAfter and isEqual when comparing ZonedDateTimes as shown by the following example in Kotlin:
import java.time.ZonedDateTime
import java.time.ZoneId
import java.time.ZoneOffset
fun main() {
val a = ZonedDateTime.of(2022, 1, 1, 13, 0, 0, 0, ZoneId.of("Europe/Oslo"))
val b = ZonedDateTime.of(2022, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC)
println("a = $a")
println("b = $b")
println()
println("a < b: ${a < b}")
println("a > b: ${a > b}")
println("a == b: ${a == b}")
println()
println("a.isBefore(b): ${a.isBefore(b)}")
println("a.isAfter(b): ${a.isAfter(b)}")
println("a.isEqual(b): ${a.isEqual(b)}")
}
Output:
a = 2022-01-01T13:00+01:00[Europe/Oslo]
b = 2022-01-01T12:00Z
a < b: false
a > b: true
a == b: false
a.isBefore(b): false
a.isAfter(b): false
a.isEqual(b): true
What is the difference?