Spring MVC Date and CustomDateEditor problem on simple text Field?

Up vote 0 down vote favorite share g+ share fb share tw.

Hello I have a problem with Spring MVC 3.0 + CustomDateEditor and one field of type java.util. Date In my controller I have : protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { DateFormat df = new SimpleDateFormat("hh:mm MM/dd/yyyy"); df. SetLenient(false); CustomDateEditor editor = new CustomDateEditor(df, false); binder.

RegisterCustomEditor(Date. Class, editor); } Than when the user types some date using this pattern example "10:10 10/10/2009" the form is validated correctly and is submitted BUT if there are other validation errors the form is shown again and the value of the "date" textfield looks like: Sat Oct 10 10:10:00 CEST 2009. Why it displays this instead of the "10:10 10/10/2009"?

Is this a bug or? Any ideas? If I am correct there are 2 methods in the CustomDateEditor.

This one : public String getAsText(){ Date value = (Date)getValue(); return ((value! = null)? This.dateFormat.

Format(value) : ""); } Which maybe should be called when the date object is asked for a text value. And the other one : public void setAsText(String text) throws IllegalArgumentException I think that only one of them is invoked for some reason and the other one is not invoked don't know why. Any ideas?

My form looks just like that : ... MOCKUP(hh:mm MM/dd/yyyy) ... spring spring-mvc link|improve this question edited Mar 8 '10 at 10:12 asked Mar 8 '10 at 8:54JOKe158110 33% accept rate.

This should be working. The relevant code is the getDisplayString() method of AbstractFormTag. I suggest using remote debugging to track the execution of this method, and see where it's going wrong.

– skaffman Mar 8 '10 at 13:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions