0

我将 JavaFx 与 jfxtras 库一起使用。我将“议程”控件包含在我的 fxml 中,并且它在页面上正确呈现。不幸的是,相关的约会没有显示在表格上,也没有相关的事件。如何实现样本的相同行为?我在哪里可以找到有关此控件的教程?这里的java代码:

   LocalDate lTodayLocalDate = LocalDate.now();
   Agenda.Appointment[] lTestAppointments = new Agenda.Appointment[]{
       new Agenda.AppointmentImpl()
           .withStartTime(new GregorianCalendar(lTodayLocalDate.getYear(), lTodayLocalDate.getMonthValue(), lTodayLocalDate.getDayOfMonth(), 4, 00))
           .withEndTime(new GregorianCalendar(lTodayLocalDate.getYear(), lTodayLocalDate.getMonthValue(), lTodayLocalDate.getDayOfMonth(), 5, 30))
           .withSummary("A")
           .withDescription("A much longer test description")
           .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
   };
   agenda.appointments().addAll(lTestAppointments);
4

1 回答 1

0

是的,不需要教程,这个错误每个人都会偶尔犯;您正在使用 LocalDate 提供的月份来创建日历。但是,LocalDate 的月份是从 1 到 12,Calendar 的月份是从 0 到 11,所以约会实际上是今天之后的一个月。

我建议您开始使用 Java 8 Date API。

       LocalDate lTodayLocalDate = LocalDate.now();
       Agenda.Appointment[] lTestAppointments = new Agenda.Appointment[]{
           new Agenda.AppointmentImplLocal()
               .withStartLocalDateTime(lTodayLocalDate.atTime(4, 00))
               .withEndLocalDateTime(lTodayLocalDate.atTime(5, 30))
               .withSummary("A")
               .withDescription("A much longer test description")
               .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
       };
       ctrl.appointments().addAll(lTestAppointments);
于 2015-07-28T05:50:15.273 回答