For example, you want to check in Kotlin if an Instant is in the range of start and end of other two Instants you can simply do the following:
import java.time.Instant
val start = Instant.parse("2000-10-23T00:00:00Z");
val end = Instant.parse("2020-10-23T23:59:59Z");
val toTest = Instant.parse("2010-10-24T00:00:00Z");
if(toTest in start..end) println("Yes") else println("No")
which is in my opinion pretty simple to understand
And you could also write in the standard way the following to check the same:
import java.time.Instant
val start = Instant.parse("2000-10-23T00:00:00Z");
val end = Instant.parse("2020-10-23T23:59:59Z");
val toTest = Instant.parse("2020-10-24T00:00:00Z");
val result = start <= toTest && toTest <= end
if(result) println("Yes") else println("No")
My question is now is there a difference in consumed resources or in additional overhead with the range solution.
Is it better for some reason to use the standard way for checking e.g. Instants within a range?