This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes Timestamp Binding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Timestamp Binding" Watch "Timestamp Binding" New topic
Author

Timestamp Binding

Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi All,

I created a domain class in my spring mvc 2.5 application. Now I want to bind the date value
into a java.sql.Timestamp.



I created my own custom editor:




and then register it in my initbinder.


my problem is, I always get null values on the binding process. It doesnt throw any error
but it is always null in this case.

Do you have any idea why is it like this?


Sean Clark ---> I love this place!!!
Me ------> I definitely love this place!!!
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

You should use the java.text.SimpleDateFormat class' parse method to convert the String.


So you can just implement something similar in your code.
also you may want to implement the getAsText method as well so that the when the date outputs in your input field it is the same format as you expect people to input into it.

Sean


I love this place!
Mark Reyes
Ranch Hand

Joined: Jul 09, 2007
Posts: 426
Hi Sean,

Thanks. I think I know now how to do this.

 
 
subject: Timestamp Binding
 
Similar Threads
initBinder method - how does it works?
Performance question based on two cases
TimeStamp.toString() does not work as expected
Help needed with Spring binding and <form:select>
MVC 2.5 - Help with a custom PropertyEditor