This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes hibernate convert sql.Timestamp to joda.DateTime format issues 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 » Databases » Object Relational Mapping
Bookmark "hibernate convert sql.Timestamp to joda.DateTime format issues" Watch "hibernate convert sql.Timestamp to joda.DateTime format issues" New topic
Author

hibernate convert sql.Timestamp to joda.DateTime format issues

Grace Russo
Ranch Hand

Joined: Nov 08, 2010
Posts: 64
Is there hibernate annotation to specify a difference in format between what a timestamp field is in the database and what joda.Datetime expects ?

My table has a TIMESTAMP field with format "mm/dd/yyyy HH:mm:ss PM/AM".
My corresponding entity has

@Column(name = "USER_AGREEMENT")
@Type(type = "persistent_date_time")
private DateTime userAgreement;


I get an illegalArgumentException as below, and a different timestamp format is expected.

Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-
dd hh:mm:ss[.fffffffff]
at java.sql.Timestamp.valueOf(Timestamp.java:202)
at oracle.jdbc.driver.CharCommonAccessor.getTimestamp(CharCommonAccessor
.java:460)
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetIm
pl.java:796)


Report this post
T Mishra
Ranch Hand

Joined: Apr 04, 2006
Posts: 107

I think this example might be helpful.


Thanks,
Tushar (SCJP 1.5)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate convert sql.Timestamp to joda.DateTime format issues
 
Similar Threads
Oracle Date and Time problem
How to convert Timestampformat to another format
Need Help
How to fetch Date Field from excel sheet in Java
Need to update date from jsp to mysql database.