In our Java8+ code we have a legacy service returning a java.util.Date
object; we want to know if it's in a date-range (with given dates provided as ISO strings), like:
java.util.Date date = legacyService.retrieveLegacyDate(..); // won't change...
if (date.isAfter("2022-08-16") && date.isBefore("2022-10-17")) { // pseudo-code => to FIX
// date is OK, proceed....
}
How can I "fix" the pseudo-code using only the new types from the java.time API?
Note: for now I couldn't find anything (either here on S.O. or elsewhere) that deals with this kind of problem, because either it's about comparing "Dates" (the legacy object) or LocalDate/LocalDateTime/etc. but always same type objects between them.