PrimeFaces はイベントの終了時刻を表示しません。PrimeFaces Schedule Demo ではそうです。
日付を変換して分を追加する方法:
private ScheduleModel eventResourceAvailPerDay = new DefaultScheduleModel();
Date dateBeginConverted = DateUtil.minsToHours(minsBegin, dteBeginResourceAvailPerDay);
Date dateEndConverted = DateUtil.minsToHours(minsEnd, dteBeginResourceAvailPerDay);
DefaultScheduleEvent newOrResourceAvailPerDayEvent = new DefaultScheduleEvent(reason, dateBeginConverted, dateEndConverted);
eventResourceAvailPerDay.addEvent(newResourceEvent);
minsToHours
public static Date minsToHours(Integer mins, Date availDate) {
int hours = (int) Math.floor(mins / 60);
int minutes = mins - (hours * 60);
Calendar cal = Calendar.getInstance();
cal.setTime(availDate);
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), hours, minites);
return cal.getTime();
}
私のHTML出力:
<div class="fc-event-time">9:00</div>
PrimeFaces 3.5、JSF 2.0 を使用しています
PrimeFaces 標準コード:
public ScheduleController() {
eventModel = new DefaultScheduleModel();
eventModel.addEvent(new DefaultScheduleEvent("Champions League Match", previousDay8Pm(), previousDay11Pm()));
eventModel.addEvent(new DefaultScheduleEvent("Birthday Party", today1Pm(), today6Pm()));
eventModel.addEvent(new DefaultScheduleEvent("Breakfast at Tiffanys", nextDay9Am(), nextDay11Am()));
eventModel.addEvent(new DefaultScheduleEvent("Plant the new garden stuff", theDayAfter3Pm(), fourDaysLater3pm()));
}
private Calendar today() {
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 0, 0, 0);
return calendar;
}
private Date previousDay8Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.DATE, t.get(Calendar.DATE) - 1);
t.set(Calendar.HOUR, 8);
return t.getTime();
}
PrimeFaces HTML 出力:
<div class="fc-event-time">9:00 - 11:00</div>