coastgasil.blogg.se

Grails date minus minutes
Grails date minus minutes





grails date minus minutes

Next, I want to skip Saturdays and Sundays, so I create another set incorporating two enum values of – SATURDAY and SUNDAY. Note as well that I’m using the Groovy shorthand to create a List and then coercing it to a Set. Note that the default pattern for LocalDate.parse() is ‘ yyyy-MM-dd’, so I’ve left the pattern out here.

grails date minus minutes

Println "$ working day(s) between $start and $end"Ĭopy this code into a file called wdb.groovy and run it from the command line to see the results: $ groovy wdb.groovyįirst, I create a set of holiday dates (these are Chile’s “días feriados” for 2021, in case you wondered) called holidaySet. Here’s the script: import java.time.*ĭef start = LocalDate.parse('','yyyy-MM-dd')ĭef end = LocalDate.parse('','yyyy-MM-dd') Since Java 8, time and date calculations have been folded into a new package called java.time, and Groovy provides access to that. For this article, I'm using my distro's OpenJDK11 release and SDKMan's latest Groovy release.

#Grails date minus minutes install#

Alternately, you can install Groovy by following the instructions on the .Ī nice alternative for Linux users is SDKMan, which can be used to get multiple versions of Java, Groovy, and many other related tools. Both a recent and decent version of Java and Groovy might be in your Linux distribution's repositories.

grails date minus minutes

Groovy is based on Java, so it requires a Java installation. This is the perfect sort of problem to solve with a tiny Groovy script. So, yeah, I had to figure out how many weeks between -31 inclusive. eBook: An introduction to programming with Bash.Try for free: Red Hat Learning Subscription.







Grails date minus minutes