datetime-tz with JDBC and Hibernate

Posted by sedge on 31-May-2011 18:56

I woud have expected a datetime-tz to be returned in ISO8601 format, which is:

YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)

Instead it comes back as:

2011-05-31 17:36:57:226 + 10:00

- The "T" is missing from between the Date and Time

- The separator between the seconds and decimal is a ":" rather than a "."

- The spaces in the timezone offset " + " don't help either.

Which is proving hard to parse into a Java Date or Joda DateTime. I am tempted to "edit" the string that is retuened but I can see problems with that in the future.

Likewise we need to send the value to Openedge as: 2011-06-01 09:37:59.213+10:00. If a DateTime is sent in ISO8601 format it is rejected by OpenEdge.

This is proving very problematic with Hibernate:

- If we define a DateTime field in an Entity as Date or Datetime it Inserts in OpenEdge OK but a read fails because Hibernate can't interpret the value that comes back form OpenEdge.

- We've had to define the Field as a String and develop conversion routines to format to and from OpenEdge.

Does anyone have any direct expereience with this that could help? We've spent a lot of time mucking around with something that should be simple.



All Replies

Posted by Admin on 01-Jun-2011 03:21

Hi Steve,

pretty sure you actually want to let the timestamp as it is and don't lead hibernate into thinking it's a string

What error do you get is you set it as timestamp? I think the error comes from the dialect and you should replace

registerColumnType(Types.TIMESTAMP, "datetime-tz");


registerColumnType(Types.TIMESTAMP, "timestamp");

datetime-tz is the 4GL date type, the SQL equivalent for JDBC driver is timestamp... see if that makes any difference.

This thread is closed