This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes f:convertDateTime issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "f:convertDateTime issue" Watch "f:convertDateTime issue" New topic
Author

f:convertDateTime issue

Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
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


SCEA part I,TOGAF Foundation
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
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.



Regards,<br />Joe<br /> <br />"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."<br />--Martin Golding
Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
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
Bhaskar GR
Greenhorn

Joined: Jun 13, 2008
Posts: 28
String date=dateofcertificationInput.getSubmittedValue().toString();
SimpleDateFormat df=new SimpleDateFormat("dd/mm/yyyy");
dateOfCertification=df.parse(date);
Date d=new Date(date);
cto2.setDateOfCertification(d);


<hutputText 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>
 
 
subject: f:convertDateTime issue
 
Similar Threads
Weird Conversion Error inputText behavior with Dates
f:convertDateTime
JSF Date not populating value
date converter
Date Validation