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);
分钟到小时
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>