2 Replies Latest reply on Jul 29, 2010 8:07 AM by andreandradesilva

    Problems with Calendar and timeZone. Wrong date in October

    andreandradesilva

      Hi All.

       

      I'm experiencing a frustrating problem with rich:calendar and timezones.

      When I try to select 2010 October 17th, it goes to 2010 October 16th!

      I saw that this can happen because the timezone. So this is my scenario:

       

      -- faces-config.xml

          <application>
              <locale-config>
                  <default-locale>pt_BR</default-locale>
                  <supported-locale>pt_BR</supported-locale>
              </locale-config>
          </application>

       

      -- my managed bean

      public class TestBean {

       

          private String meetingDate;
          private Locale locale = new Locale("pt", "BR");
          private TimeZone timeZone = TimeZone.getTimeZone("America/Sao_Paulo");

       

          public TimeZone getTimeZone() {
              return timeZone;
          }

       

          public Locale getLocale() {
               return locale;
           }

       

          public String getMeetingDate() {
              return meetingDate;
          }

       

          public void setMeetingDate(String meetingDate) {
              this.meetingDate = meetingDate;
          }

       

      }

       

      -- JSP file

      <rich:calendar  value="#{testBean.meetingDate}" timeZone="#{testBean.timeZone}"  locale="#{testBean.testLocale}" datePattern="dd/MM/yyyy">
                               <f:convertDateTime  timeZone="#{testBean.timeZone}" locale="#{testBean.locale}"  pattern="dd/MM/yyyy" />
      </rich:calendar>

       

      Any idea on what can be causing this problem ?