This recipe shows how to create a 'vanilla' schedule of periods between two dates.
// Create a calendar with today's date
Calendar today = Calendar.getInstance();
// Ask the schedule generator to create
// a list of periods
// starting today, continuing for 5Y
// where the frequency is quarterly
// and with no stub
List
ScheduleGenerator.generateSchedule(
today,
"5Y",
Frequency.QUARTERLY,
StubType.NONE
);
// Print out the periods in the schedule
for(Period period: schedule) {
// Use the ISDADateFormat class to help
// format the calendars properly
System.out.println(
ISDADateFormat.format(
period.getStartCalendar()
)+
" to "+
ISDADateFormat.format(
period.getEndCalendar()
)
);
}
Click here for the full source code.