Changeset 552 for trunk/grails-app/services/DateUtilService.groovy
- Timestamp:
- May 31, 2010, 1:29:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/DateUtilService.groovy
r476 r552 99 99 100 100 /** 101 * Get the date one year in the future. 102 * @param date The Date object to start with. 103 * @returns A Date object one year in the future. 101 * Get the date plus x years. 102 * @param date The Date object to start with, defaults to today. 103 * @param plusYears The number of years to add, defaults to 1. 104 * @returns A Date object adjusted by x years. 104 105 */ 105 public static Date getNextYear(Date date) {106 public static Date plusYear(Date date = new Date(), Integer plusYears = 1) { 106 107 use(TimeCategory) { 107 date + 1.years 108 } 109 } 110 111 /** 112 * Get the date one year ago. 113 * @param date The Date object to start with. 114 * @returns A Date object one year ago. 115 */ 116 public static Date getPreviousYear(Date date) { 117 use(TimeCategory) { 118 date - 1.years 108 date + plusYears.years 119 109 } 120 110 }
Note: See TracChangeset
for help on using the changeset viewer.