def sql= new Sql(datasource) def dateString = '20100101' def date = Date.parse('yyyyMMdd', dateString) while (dateString < '20991231') { if (HolidayService.isDayOffDueToHoliday(dateString)) { sql.execute '''INSERT INTO HOLIDAYS (HOLIDAY_DATE) VALUES (?, 'E010152')''', date.format('yyyy-MM-dd') } date = date.next() dateString = date.format('yyyyMMdd') }
Populating a Holiday Table
in
Groovy
- on 1:39 PM
- No comments
Our company has a Java service which determines if a date is a holiday, but we were working on some reports that needed that data in a database. So the following groovy script was used to populate a holiday table for the holidays for the remainder of the century.
Post a Comment