Hey Mike,

On 2011-07-28, at 0:52 , Mike Schrag wrote:

>> But up to now the worst is when using a java.sql.ResultSet and asking 
>> calling getTimestamp which now returns a Date instead of a Timestamp.
> wait ... what? the signature for that method is java.sql.Timestamp -- it 
> can't return a date. Are you saying you're getting a ClassCastException from 
> inside your jdbc driver in your driver's IMPLEMENTATION of getTimestamp?

Actually, it's not entirely correct, it will return a Timestamp but the 
getTimestamp will in some cases not parse correctly because the date format is 
broken, instead of YYYY-MM-DD we ended up with YYYY/MM/DD. In the older 
versions we never experienced the parsing error.

We used to do this:
ResultSet row = <get my result set>
NSTimestamp timestamp = new NSTimestamp(row.getTimestamp(COLUMN_NAME)); // 
timestamp is never null

Now we have to take the following detour:

NSTimestamp timestamp = null;
if (row.getObject(COLUMN_NAME) instanceof Timestamp) {
        Object dateObject = row.getObject(COLUMN_NAME);
        Timestamp time = ((Timestamp) dateObject);
        java.util.Date date = java.utilDate(time.getTime());
        timestamp = new NSTimestamp(date);
}
else {
        timestamp = new NSTimestamp(row.getTimestamp(COLUMN_NAME));
}

We have to do the instanceof check, otherwise using row.getObject(COLUMN_NAME) 
resets the time in the date to midnight (depending on timezones ...).

So, you're right, it does return a Timestamp.

Cheers,

Edgar


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-deploy mailing list      (Webobjects-deploy@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-deploy/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to