7

I am trying to use joda-time with its Scala wrapper.

Saying val dt is a DateTime and contains a date (zero time), how do I get the date of the day befor it? dt - 1.days doesn't work and gives

"type mismatch" ("found: org.scala_tools.time.Imports.DateTime, required: ?{val -:?}").

Scala-time examples like 2.hours + 45.minutes + 10.seconds don't work either saying that hours is not a member of an Int.

Joda-time examples like DateTime.dayOfWeek().addToCopy(3) don't work either as dayOfWeek, for example, is not a member of org.scala_tools.time.Imports.DateTime.

Formatted DateTimeinput and output seem to work as meant.

UPDATE: Seems to be a bug of NetBeans IDE.It shows the error, while compiler compiles ok and the program works as expected with dt - 1.days syntax.

missingfaktor
  • 90,905
  • 62
  • 285
  • 365
Ivan
  • 63,011
  • 101
  • 250
  • 382
  • 2
    Note that `dayOfWeek` actually *is* a member of org.scala_tools.time.Imports.DateTime, since Imports.DateTime is just an alias for org.joda.time.DateTime. The scala-friendly methods are added in the RichDateTime class. – Aaron Novstrup Sep 03 '10 at 23:35

2 Answers2

6

Seems to be a bug of NetBeans IDE. It shows the error, while compiler compiles ok and the program works as expected with "dt - 1.days" syntax.

Ivan
  • 63,011
  • 101
  • 250
  • 382
2

It seems that the code cannot find the implicit conversions. Are you sure you import org.scala_tools.time.Imports._ in the scope that you are using it?

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
  • I have import org.scala_tools.time.Imports._ right after package declaration. DateTime type works, as I've said, from which I conclude that I've imported it ok. – Ivan Sep 03 '10 at 22:48
  • 1
    Seems to be a bug of NetBeans IDE.It shows the error, while compiler compiles ok and the program works as expected with "dt - 1.days" syntax. – Ivan Sep 03 '10 at 23:21