File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Timestamp Binding" Watch "Timestamp Binding" New topic

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

Joined: Jul 15, 2009
Posts: 377


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.


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.

I agree. Here's the link:
subject: Timestamp Binding
It's not a secret anymore!