0

Hi I try make schedule using primaface but the end date showing one day before the specified date

enter image description here

And this bean

 @PostConstruct
    public void init() {
        eventModel = new DefaultScheduleModel();

        lazyEventModel = new LazyScheduleModel() {

            @Override
            public void loadEvents(Date start, Date end) {
                List<Group> listproject = new GroupDAO().retriveAll("", new Object[] {});
                Calendar date = Calendar.getInstance();
                Calendar dates = Calendar.getInstance();

                for (int i = 0; i < listproject.size(); i++) {

                    date.setTime(listproject.get(i).getCreateAt());

                    dates.setTime(listproject.get(i).getUpdateAt());

                    addEvent(new DefaultScheduleEvent(listproject.get(i).getName(), date.getTime(), dates.getTime()));
                    System.out.println(listproject.get(i).getName()+ listproject.get(i).getCreateAt() + listproject.get(i).getUpdateAt());
                }


            }  
        };
    }

The Xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
template="/user_templates/template.xhtml">
<ui:define name="metadata">
</ui:define>
<ui:define name="content">
    <p:layout>
        <p:layoutUnit position="center">
            <h:form id="formId">
                <h:panelGrid columnClasses="value">
                    <p:schedule value="#{testBean.lazyEventModel}" timeZone="GMT+7" > <!-- view="agendaWeek" bisa dipake buat search -->
                        <p:ajax event="dateSelect" listener="#{testBean.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
                        <p:ajax event="eventSelect" listener="#{testBean.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
                    </p:schedule>
                </h:panelGrid>

                 <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
        <h:panelGrid id="eventDetails" columns="2">
        <p:outputLabel for="title" value="Titles:" />
        <p:inputText id="title" value="#{testBean.event.title}" required="true" />

        <p:outputLabel for="from" value="From:" />
        <p:calendar id="from" value="#{testBean.event.startDate}" pattern="dd/MM/yyyy HH:mm" showTime="true" appendTo="@(body)"  />

        <p:outputLabel for="to" value="To:" />
        <p:calendar id="to" value="#{testBean.event.endDate}" pattern="dd/MM/yyyy HH:mm" showTime="true" appendTo="@(body)" />

        <!-- <p:outputLabel for="allDay" value="All Day (see #1164):" />
        <h:selectBooleanCheckbox id="allDay" value="#{testBean.event.allDay}" /> -->

        <p:commandButton type="reset" value="Reset" />
        <p:commandButton id="addButton" value="Save" action="#{testBean.addEvent}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />
    </h:panelGrid>
</p:dialog>    
            </h:form>
        </p:layoutUnit>
    </p:layout>
</ui:define>

previously I used Date for set value on cratedAt and updateAt on GroupDAO for get value from database but it show same thing like the picture for the start date and then I change it into Timestamp, and the star date showing like I want but the end date showing like that, and I don't know the problem is

And I just realized just that value have wrong end date

Steven a
  • 43
  • 4
  • Which instance of Date class are you using (util)? Can you post also the definition of Group class? Have you tried adding localization in each step (query, lazy load, xhtml)? – WoAiNii Apr 14 '20 at 10:32
  • 1
    Please read https://stackoverflow.com/tags/jsf/info about the [mcve] please. Try dropping templates, includes etc... (as well as the layout etc...) – Kukeltje Apr 14 '20 at 12:13
  • 2
    Does this answer your question? [Set a default time zone for f:convertDateTime](https://stackoverflow.com/questions/7490954/set-a-default-time-zone-for-fconvertdatetime) – areus Apr 14 '20 at 12:51
  • Oh and 1: it is PrimeFaces (with an s at the end) and 2: The displaying of the date is in the calendar and in no way (technically) schedule related and 3: (I did not downvote yet), see https://idownvotedbecau.se/beingunresponsive – Kukeltje Apr 16 '20 at 08:07

0 Answers0