Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timestamp Binding

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic