Create a schedule

Submitted by morgdx on Wed, 2006-10-25 20:44.

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 schedule =
  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.

Vote Result
Score: 0.0, Votes: 0
email this story

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
More information about formatting options Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.