I expected the first one to be correct.
As ZonedDateTime implements ChronoZonedDateTime<LocalDate>
, I tried to use latter as type parameter. I guess this didn't work due to type erasure, but I'm not sure.
But only third range is compiled correctly. Could you please explain why?
import org.apache.commons.lang3.Range;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.chrono.ChronoZonedDateTime;
public class Test {
public static void main(String[] args) {
Range<ZonedDateTime> range1 = Range.between(ZonedDateTime.now(), ZonedDateTime.now());
Range<ChronoZonedDateTime<LocalDate>> range2 = Range.between(ZonedDateTime.now(), ZonedDateTime.now());
Range<ChronoZonedDateTime<?>> range3 = Range.between(ZonedDateTime.now(), ZonedDateTime.now());
}
}