Is there any way to represent infinite future / end of time in Java?
问题 Until now I've been using Instant.MAX to mean infinite future or end of time. For example when calculating the minimum timestamp of a collection of timestamps: Iterator<Instant> it = .... Instant minTs = Instant.MAX; while(it.hasNext()) { Instant curr = it.next(); minTs = curr.isBefore(minTs) ? curr : minTs; } But I realized that there are several issues with using Instant.MAX to represent "infinite future": Instant.MAX is not the same as OffsetDateTime.MAX Instant.MAX.toEpochMilli() raises