2 Replies Latest reply on Mar 8, 2013 2:08 AM by nishitjani

    How to set the date pattern on jsf pages?

    nishitjani

      code.jpg

       

      Using code : 1, I got the date from database is 2012-09-03 00:00:00.0

       

      Now, I want to set the date pattern to dd-MM-yyyy.

       

      So my required output is 03-09-2012. 

       

      But using  code : 2  (after setting the pattern)

       

      I am getting the output is 02-09-2012  Whatever date is in database, it shows output less by one day.

       

      In advance thanks.

        • 1. Re: How to set the date pattern on jsf pages?
          avijra

          Hi Nishit ,

           

          Not sure if still you are facing this issue , but if yes then you can use the following context params in your web.xml

           

          <context-param>

                  <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>

                  <param-value>true</param-value>

              </context-param>

          • 2. Re: How to set the date pattern on jsf pages?
            nishitjani

            Got the solutions by applying below code :

            Just need to add time-zone

             

            <rich:column>

                 <f:facet name="header">

                      <h:outputText value="Expiry Date">

                 </f:facet>

                 <h:outputText value="item.endDate">

                      <f:convertDateTime pattern="dd-MM-yyyy" timeZone="Asia/Calcutta" />

                 </h:outputText>

            </rich:column>