How to compare date with current date in groovy

I have a validFrom and validTo date field in my domain class in a grails project. I want to create a service based on its verification. can someone tell me how to check if it is more or less than the current system date?

+4
source share
1 answer

it

Date now = new Date() if (validFrom.before(now) && validTo.after(now)) { //valid for this moment } 
+6
source

Source: https://habr.com/ru/post/1411794/


All Articles