Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate convert sql.Timestamp to joda.DateTime format issues

 
Grace Green
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this example might be helpful.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic