1 Reply Latest reply on Apr 16, 2015 2:34 AM by ppitonak

    rich:calendar timeZone attribute is not working properly

    pradeep.panda

      I mentioned tomezone as "timeZone="#{calendarBean.timeZone}" in my rich:calendar tag and I have time zone pull down menu when I change the value over there , I am calling value change ajax call to change the time zone, but on click of submit always its giving IST time i.e my system time.

      Could you please help me or give some example on timeZone attribute of rich calendar.

       

      Below is my code, please help out me on this

      **.xhtml
      --------------
      <h:form><table><tr>
      <td style="padding: 4px;"><h:outputText value="Disabled rich calendar" styleClass="OTtagGroupRowLabel"/></td>

      <td style="padding: 4px;"><rich:calendar value="#{calendarBean.selectedDateValue}" id="calendarTimeZoneId" datePattern="dd/M/yy hh:mm a" showWeeksBar="false" timeZone="#{calendarBean.timeZone}

      ">
      </rich:calendar></td>
      <td style="padding: 4px;"><h:selectOneListbox value="#

      {calendarBean.timeZoneSelectValue}

      ">
      <f:selectItem itemValue="Asia/Calcutta" itemLabel="Asia/Calcutta" />
      <f:selectItem itemValue="Europe/London" itemLabel="Europe/London" />
      <f:selectItem itemValue="America/Phoenix" itemLabel="America/Phoenix" />
      <f:selectItem itemValue="Pacific/Galapagos" itemLabel="Pacific/Galapagos" />
      <f:selectItem itemValue="PST" itemLabel="PST" />
      <a4j:ajax event="change" render="calendarTimeZoneId" />
      </h:selectOneListbox>
      </td>
      <td style="padding: 4px;"><a4j:commandButton render="timeZoneOut" value="#

      {bundle.calendarCreate_Submit}

      "/></td>
      </tr>
      </table>
      <br/>
      <h:outputText id="timeZoneOut" value="#

      {calendarBean.selectedDateValue}

      "/>
      <br/><br/>
      </h:form>

      ManagedBean
      ---------------
      @ManagedBean(name = "calendarBean")
      @ViewScoped
      public class CalendarBean {

      private Date datevalue = null;
      private String timeZoneSelectValue="PST";
      private TimeZone timeZone;
      private Date selectedDateValue;

      public Date getCalendarValue()

      { return (datevalue != null) ? (Date) datevalue.clone() : null; }

      public void setCalendarValue(Date value)

      { this.datevalue = (Date) value.clone(); }

      public String getTimeZoneSelectValue()

      { return timeZoneSelectValue; }

      public void setTimeZoneSelectValue(String timeZoneSelectValue)

      { this.timeZoneSelectValue = timeZoneSelectValue; }

      public TimeZone getTimeZone()

      { //return timeZone; timeZone = timeZoneSelectValue == null ? null : TimeZone.getTimeZone(timeZoneSelectValue); return timeZone; }

      public void setTimeZone(TimeZone timeZone)

      { this.timeZone = timeZone; }

      public Date getSelectedDateValue()

      { return selectedDateValue; }

      public void setSelectedDateValue(Date selectedDateValue)

      { this.selectedDateValue = selectedDateValue; }

      }

        • 1. Re: rich:calendar timeZone attribute is not working properly
          ppitonak

          Hi,

           

          I believe that it works as expected because you store your data inside java.util.Date instance which doesn't know timezone therefore h:outputText will use the default of your server.

           

          Try to modify outputText like this:

           

          <h:outputText id="timeZoneOut" value="#{calendarBean.selectedDateValue}">

            <f:convertDateTime timeZone="#{calendarBean.timeZoneSelectValue}" />

          </h:outputText>

           

          Regards,

          Pavol