In Groovy 2.5 which is used in Grails 4 the date extensions were pulled out to a separate dependency.
Use the docs changing the URL to the version of G4 you are using to look up the Groovy version you are using:
https://grails.github.io/legacy-grails-doc/4.0.0/guide/single.html#whatsNew
Then go here and find that version for the date libraries:
https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-datetime
For example, if you are on 4.0.0 in the docs it says it's using groovy 2.5.6 so you would add this dependency to your build:
implementation 'org.codehaus.groovy
groovy datetime2.5.6'
If I were you after you're done migrating to 4 I would upgrade to 5 which shouldn't be very difficult, and then be ready to upgrade whenever Grails 7 comes out.