@Override public DateMidnight getStartDateMidnight(ReadableInstant instant) { final MonthDay instantMonthDay = new MonthDay(instant); // If the quarter wraps a year boundary AND // the instant MonthDay is before the start AND // the end is after the instant MonthDay // then shift the start year back by one to deal with the year boundary if (this.end.isBefore(this.start) && instantMonthDay.isBefore(this.start) && this.end.isAfter(instantMonthDay)) { return this.start.toDateTime(new DateTime(instant).minusYears(1)).toDateMidnight(); } return this.start.toDateTime(instant).toDateMidnight(); }
@Override public DateMidnight getEndDateMidnight(ReadableInstant instant) { final MonthDay instantMonthDay = new MonthDay(instant); // If the quarter wraps a year boundary AND // the end is NOT after the instant MonthDay AND // the instant MonthDay is NOT before the start // then shift the end year forward by one to deal with the year boundary if (this.end.isBefore(this.start) && !this.end.isAfter(instantMonthDay) && !instantMonthDay.isBefore(this.start)) { return this.end.toDateTime(new DateTime(instant).plusYears(1)).toDateMidnight(); } return this.end.toDateTime(instant).toDateMidnight(); }