IllegalArgumentException using joda-time DateTimeZone Class

Hello,

I used joda-time in some prototyping code to do a simple time zone
conversion and ran into an issue. It’s almost certainly related to the
version of joda-time on the classpath (1.6) and that which is bundled
with JRuby (I am running 1.7.0 dev).

I’m only curious how to make this work, as the required functionality
has been implemented and tested in Java. (Ideally however I would be
able to migrate the lonely JUnit test to our JRuby/RSpec suite).

java_import org.joda.time.DateTime
java_import org.joda.time.DateTimeZone

local = DateTime.new
tz = org.joda.time.DateTimeZone.forID(‘GMT0’)
tz.class.should == org.joda.time.tz.FixedDateTimeZone # n.b. we get back
a FixedDateTimeZone…

gmt = DateTime.new(tz) # woops:

Failure/Error: gmt = DateTime.new(tz)

 NativeException:
   java.lang.IllegalArgumentException: No instant converter found

for type: org.joda.time.tz.FixedDateTimeZone
# org/joda/time/convert/ConverterManager.java:165:in
getInstantConverter' # org/joda/time/base/BaseDateTime.java:169:in
# org/joda/time/DateTime.java:168:in <init>' # sun/reflect/NativeConstructorAccessorImpl.java:-2:innewInstance0’
# sun/reflect/NativeConstructorAccessorImpl.java:39:in
newInstance' # sun/reflect/DelegatingConstructorAccessorImpl.java:27:innewInstance’
# java/lang/reflect/Constructor.java:513:in `newInstance’

===

And I’d like to take this opportunity to thank the JRuby community for
all their great hard work.

Regards,

Edward

$ jruby --version
jruby 1.7.0.dev (ruby-1.9.2-p136) (2011-10-03 731b4e2) (Java HotSpot™
64-Bit Server VM 1.6.0_27) [linux-amd64-java]

there is jar file (maven artifact) jruby-core.jar which has joda-time
as dependency and there you can choose your version. but I do not
think there are any development snapshots of those and this artifact
might be still broken in the 1.6.x branch (JRUBY-5848).

what you can do is make sure that your joda-time jar is first in the
classpath or get loaded first from the classloader. maven for example
obeys the order in which you declare dependencies other build systems
I do not know.

maybe that helps a bit.
regards, Kristian