/** * Generates bi-weekly Periods for the whole year in which the given Period's * startDate exists. */ @Override public List<Period> generatePeriods( DateTimeUnit start ) { Calendar calendar = getCalendar(); List<Period> periods = new ArrayList<>(); DateTimeUnit date = adjustToStartOfBiWeek( start, calendar ); date = adjustToStartOfBiWeek( calendar.fromIso( date.getYear(), 1, 1 ), calendar ); for ( int i = 0; i < calendar.weeksInYear( start.getYear() ) / 2; i++ ) { periods.add( createPeriod( date, calendar ) ); date = calendar.plusWeeks( date, 2 ); } return periods; }
/** * Generates weekly Periods for the whole year in which the given Period's * startDate exists. */ @Override public List<Period> generatePeriods( DateTimeUnit start ) { Calendar calendar = getCalendar(); List<Period> periods = new ArrayList<>(); start = new DateTimeUnit( start ); // create clone so we don't modify the original start DT start.setMonth( 1 ); start.setDay( 4 ); start = adjustToStartOfWeek( start, calendar ); for ( int i = 0; i < calendar.weeksInYear( start.getYear() ); i++ ) { DateInterval interval = calendar.toInterval( start, DateIntervalType.ISO8601_WEEK ); periods.add( new Period( this, interval.getFrom().toJdkDate(), interval.getTo().toJdkDate() ) ); start = calendar.plusWeeks( start, 1 ); } return periods; }
.getByNameIgnoreCase( dateUnitType.getName() ); if ( periodType == null || week < 1 || week > calendar.weeksInYear( year ) ) if ( periodType == null || week < 1 || week > calendar.weeksInYear( year ) )
if ( calendar.isoWeek( date ) == calendar.weeksInYear( year ) )