Ruby Time differs from Java's time (Date)

Hey!

There was a bug with Time around BC in JRuby 1.7.x that has been fixed
in a
recent release - but I still can not get AR-JDBC compatibility around
this
(with prepared-statements) due different time interpretation in Ruby and
Java for the same milliseconds.

So having a (ruby) Time that’s BC ends up “messing up” the date as it
gets
to be a (java) Date.

Joda’s underlying (RubyTime internals) DateTime seems to be correct (I
am
getting the millis from it) but feeding a java.sql.Timestamp the same
millis value does get interpreted as a different date :

time = Time.new -1, 12, 31, 23, 59, 59, 0
=> -0001-12-31 23:59:59 UTC
time.to_f
=> -62167219201.0
time_millis = (time.to_f * 1000).round
=> -62167219201000
jdate = time.to_java
=> #Java::JavaUtil::Date:0x5a360f2b
jdate.toString
=> “Sat Jan 03 00:59:59 CET 1”
jdate.getTime
=> -62167219201000
java.text.SimpleDateFormat.new(“yyyy-MM-dd HH:mm:ss”).format jdate
=> “0001-01-03 00:59:59”

Just ignore the fact that the Time and Date are in different time-zones

that’s taken care of but still the date seems to be quite messed up …
it’s still :

<-0001-12-31 23:59:59> (set) vs. <-0001-01-02 23:59:59> (get - when
reading
the set value)

Anyone knows if this is a JDK Calendar issue or am I missing something
(I’ve tried making the TZ used is UTC from the Java part but got the
same) ?

Thanks for pointers & ideas, K.