2 Replies Latest reply on Jul 4, 2012 3:11 AM by Sabarinath Selvaraj

    How can I convert the pattern that the rich:calendar(richfaces 4.2.2) submits

    Sabarinath Selvaraj Newbie




      I am used the following code in JSF page :


      <rich:calendar id="processEndTime"


                   locale="en/US" popup="true" datePattern="MM/dd/yyyy"


                   cellWidth="24px" cellHeight="22px" style="width:200px" disabled="false">



      when i submit the form i got the calendar value in the following format (in managed bean) :


      Tue Jul 03 00:00:00 IST 2012


      I need the date in "%Y-%m-%d" format while submitting the rich:calendar.


      can i get the date value other than this "Tue Jul 03 00:00:00 IST 2012 " format?




        • 1. Re: How can I convert the pattern that the rich:calendar(richfaces 4.2.2) submits
          Jan Papousek Newbie



          in the managed bean you have a value of type Date, so the pattern doesn't make sense here. When I have the following code, everything works as expected. You have to use a converter when you print the date on the client side.



          public class TestBean implements Serializable {
              private Date value;
              public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("UTC");
              public TimeZone getTimeZone() {
                  return TIME_ZONE;
              public Date getValue() {
                  return value;
              public void setValue(Date value) {
                  this.value = value;



                              <rich:calendar datePattern="MM/dd/yyyy" locale="en/US" value="#{testBean.value}" timeZone="#{testBean.timeZone}">
                                  <a4j:ajax render="output"/>
                              <br />Output:
                              <h:outputText id="output" value="#{testBean.value}">
                                  <f:convertDateTime pattern="MM/dd/yyyy" timeZone="#{testBean.timeZone}" />

          The full application is available on GitHub: https://github.com/papousek/richfaces-sanbox/tree/thread202093