aspose file tools*
The moose likes Struts and the fly likes struts2 date conversion question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 date conversion question" Watch "struts2 date conversion question" New topic
Author

struts2 date conversion question

Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Hello guys,

I would just like to ask how is a Date (in string) from a form is converted into java.util.Date object in struts2 by default.
I have noticed this strange behavaior, I have I timestamp/lastUpdated field displayed in the form (debugging purposes only),
when on submit the form failed the validation, the page will stay on the current page (with the form) with the unsaved data.
Now the problem is, the timestamp/lastmodified field value has been changed. Supposedly the field contains both the date and the time,
but now it only contains the date and the time was set to zero (the time part is dropped).

Now whenever I submit a valid form, my application will generate an error again:



This is because I implemented versioning/timestamping with my hibernate. The theory I have in mind is that when the object in my action class recieves
the value of the form, the timestamp/lastUpdate field was changed such that the time part of it was dropped, and when hibernate try to check the timestamp,
it failed because it is not anymore equal. And sure enough, when I tried to retrieve the timestamp / lastupdate field of the object to be saved before I invoke save
here are the values:



How do I prevent struts from dropping the time part of my timestamp field.
Is this really the default handling of struts with Date conversion (dropping time part), or have I done it incorrectly?

please advise
-marckun

ps: I plan to create a custom converter for my timestamp/lastmodified field, by it is not working, I dont know what's the problem.


-marckun
Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Hello guys,

Mind sharing any inputs?

Thanks,

marckun
 
Consider Paul's rocket mass heater.
 
subject: struts2 date conversion question
 
Similar Threads
ajax and struts2
Struts2 QUERY Regarding Built in Type Conversions in Struts2 Framework
Converet from java.sql.Timestamp to java.util.Date
get time information from oracle DATE field
Struts2 Validation problem