Type value plusHours is not a member of org.joda.t

2019-08-10 19:31发布

问题:

I'm using Scala and Joda time, but I can't use most methods.

For example this works fine

var now = DateTime.now()

But this doesn't

var now = DateTime.now()
var then = now.plusHours(2)

Type value plusHours is not a member of org.joda.time.DateTime

If i build i receive also these errors:

error while loading DateTime, Missing dependency 'class org.joda.convert.FromString', required by C:\Documents and Settings\Vallo\Mis documentos\Downloads\joda-time-2.2.jar(org/joda/time/DateTime.class) TP4 Unknown Scala Problem

error while loading DateTimeZone, Missing dependency 'class org.joda.convert.FromString', required by C:\Documents and Settings\Vallo\Mis documentos\Downloads\joda-time-2.2.jar(org/joda/time/DateTimeZone.class) TP4 Unknown Scala Problem

error while loading AbstractInstant, Missing dependency 'class org.joda.convert.ToString', required by C:\Documents and Settings\Vallo\Mis documentos\Downloads\joda-time-2.2.jar(org/joda/time/base/AbstractInstant.class) TP4 Unknown Scala Problem

(the file C:\Documents and Settings\Vallo\Mis documentos\Downloads\joda-time-2.2.jar exists)

However, methods like DateTime.isBefore or .isAfter works fine. I've got the feeling that static methods are the only one that work for me, but I'm not sure.

Any clues? Thanks a lot.

回答1:

It seems that you might need to add joda-convert as a dependency too.