Java 8 expiration after a duration -
can't figure out how in java 8 (without calendar) simple method:
import java.time.duration; import java.util.date; [...] /** * true if date + duration before now() * @param date * @param d * @return */ public static boolean isdateexpired (date date, duration d) { // how ? }
consider getting rid of java.util.date
. when must deal due legacy code, escape java.time
equivalent , operate there:
return date.toinstant().plus(d).isbefore(instant.now());
Comments
Post a Comment