Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 6);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
int duration = 30;
List shows = new ArrayList();
Random rand = new Random();
Calendar startTime = Calendar.getInstance();
Calendar endTime = Calendar.getInstance();
// make up some random shows
for (int channel=2; channel<6; channel++) {
startTime.setTime(today.getTime());
endTime.setTime(today.getTime());
do {
duration = (1 + rand.nextInt(4)) * 30;
endTime.add(Calendar.MINUTE, duration);
String curTitle = titles[rand.nextInt(titles.length)];
shows.add(new Show(curTitle, channel,
startTime.getTime(), endTime.getTime()));
startTime.setTime(endTime.getTime());
} while (endTime.get(Calendar.DATE) == today.get(Calendar.DATE));
}
Collections.sort(shows);
return (Show[]) shows.toArray(new Show[0]);