IllegalArgumentException using joda-time DateTimeZone Class


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 =
tz = org.joda.time.DateTimeZone.forID(‘GMT0’)
tz.class.should == # n.b. we get back
a FixedDateTimeZone…

gmt = # woops:

Failure/Error: gmt =

   java.lang.IllegalArgumentException: No instant converter found

for type:
# org/joda/time/convert/
getInstantConverter' # org/joda/time/base/
# org/joda/time/ <init>' # sun/reflect/’
# sun/reflect/
newInstance' # sun/reflect/’
# java/lang/reflect/ `newInstance’


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



$ jruby --version
jruby (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