2

I'm trying to use JodaTime in Scala. So I did

import org.joda.time.DateTime

val dt = new DateTime(2011, 10, 8, 18, 30) // try to set to 6:30 pm, Oct 8, 2011

Unfortunately, Scala thinks I'm trying to use the DateTime(Object) constructor instead of the 5 int constructor, and, not surprisingly, a Tuple5 is not the kind of Object JodaTime was expecting.

How do I tell Scala to use the 5-int constructor?

Todd

Ben James
  • 114,847
  • 26
  • 189
  • 155
Todd O'Bryan
  • 2,038
  • 15
  • 29

1 Answers1

8

It's probable that you're using an older version of JodaTime. The constructor you are trying to use didn't exist until JodaTime 2.0.

Older versions of JodaTime had no 5 param ctor. Since Scala can't find one, it assumes that you're attempting to pass in a tuple, which matches the Object ctor. You can find more details in this excellent answer.

Community
  • 1
  • 1
leedm777
  • 22,554
  • 10
  • 56
  • 85
  • You're exactly right. I was looking at Javadocs for 2.0, but the dependency I was relying on was for 1.6.2. – Todd O'Bryan Oct 09 '11 at 00:56
  • Sorry. I tried to up-vote and don't have sufficient experience. I didn't realize I could check! (Which explains why I don't have sufficient experience to up-vote.) :-) – Todd O'Bryan Oct 29 '11 at 18:54