Reputation: 2760
Can't figure out how to do in java 8 (without calendar) for this simple method:
import java.time.Duration;
import java.util.Date;
[...]
/**
* true if date + duration is before now()
* @param date
* @param d
* @return
*/
public static boolean isDateExpired (Date date, Duration d) {
// how to do ?
}
Upvotes: 2
Views: 1338
Reputation: 28153
Consider getting rid of java.util.Date
. Even when you must deal with it due to legacy code, escape into java.time
equivalent and operate there:
return date.toInstant().plus(d).isBefore(Instant.now());
Upvotes: 5