• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

f:convertDateTime issue

 
Ranch Hand
Posts: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My JSF code is as below:

<h:inputText value="#{register.dob}" id="dob" required="true" >
<f:convertDateTime type="date" pattern="MM-dd-yyyy"/>
</h:inputText>

even though I I enter a valid date (12-22-1956) in this date input field I am getting "Conversion error occurred" error.

Can any one point whats the issue ?

Thank you

--Ayub
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to see more details like the error logs and which version of JSF implementation you are using etc

In my experience, there seems to be a lot of issues with the Date converters. It does not handle exceptions well. In my applications, I use a calender to input dates. This will better the user experience and minimize the need to handle of large number of exceptional cases. I take it as a string and do the required date validations on it in the BB.

Hope I have been of some help.

 
Ayub ali khan
Ranch Hand
Posts: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,

there are not any specific error logs since the validation error is displayed on the UI.

I am using IBM JSF implementation 1.2 on Tomcat 6.0

My question is why validation error is thrown when I use the below pattern ?

<f:convertDateTime type="date" pattern="MM-dd-yyyy"/>

12-12-2006 is not a valid date for pattern "MM-dd-yyyy" ?

Thank you

--Ayub
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String date=dateofcertificationInput.getSubmittedValue().toString();
SimpleDateFormat df=new SimpleDateFormat("dd/mm/yyyy");
dateOfCertification=df.parse(date);
Date d=new Date(date);
cto2.setDateOfCertification(d);


<h:outputText value="#{msgs.DateFormat}"/>
</h:panelGroup>
<h:inputText id="dateofcertification" binding="#{certificationBean.dateofcertificationInput}" value="#{certificationBean.dateOfCertification}" required="true" >
<a4j:support event="onblur" reRender="errorMessage" ajaxSingle="true"/>
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
</h:inputText>
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic