I have the following code:
LocalDate date;
LocalDate minDate;
//constructor...
if(date.isBefore(minDate)){
throw new RuntimeException();
}
and similar with LocalDateTime:
LocalDateTime date;
LocalDateTime minDate;
//constructor...
if(date.isBefore(minDate)){
throw new RuntimeException();
}
Can I use some interface or abstract class thanks to which I wouldn't have to write the same code twice? I can't find such an interface. As you can see I am using only 'isBefore' and 'isAfter' methods.