Timestamp.java 's setNanos()
Timestamp.java 's setNanos()
- Subject: Timestamp.java 's setNanos()
- From: "Riaz Lalehzari" <email@hidden>
- Date: Tue, 25 Mar 2003 00:20:17 +0000
Hello,
I'm using Java 1.4. and have the timestamp problem with nanoseconds. Does
anyone know where the Timestamp.java file is so I can modify it?
Riaz
--------
(from Archives...)
I think I know what is happening here, but it's just a guess. I did a
FileMerge on the 1.3.1 and 1.4.0 versions of java.sql.Timestamp, and I
found that the 1.4.0 version of Timestamp now implements a getTime method
that includes nanoseconds:
public long getTime() {
long time = super.getTime();
return (time + (nanos / 1000000));
}
I'm betting good money that the JDBCColumn class is constructing an
NSTimestamp from a Timestamp object and that somewhere in the code an
assumption is made that getTime is returning a time without nanoseconds (a
correct assumption for 1.3.1) and that the nanoseconds from the Timestamp
are being added to the value from getTime or something along those lines.
This would be a plausible explanation for why I sometimes am seeing an
overflow value in setNanos and sometimes not. I don't know if I really
care about the number of nanoseconds (I don't lock on dates), so maybe I
can just override the setNanos method to fudge an overrun value. I just
tried this, and it works:
public void setNanos(int n) {
if (n < 0) {
throw new IllegalArgumentException("nanos, " +
Integer.toString(n) + ", > 999999999 or < 0");
} else if (n > 999999999) {
// Fudge to fix a bug that arose under 1.4.0 with NSTimestamp
// Feb 15, 2002 - paulrs
n -= getNanos();
if (n > 999999999) {
throw new IllegalArgumentException("nanos, " +
Integer.toString(n) + ", > 999999999 or < 0");
}
}
nanos = n;
}
---------
_________________________________________________________________
MSN Instant Messenger now available on Australian mobile phones. Go to
http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.