Trouble with DateTimeField

33 views
Skip to first unread message

Daniel Eggert

unread,
May 13, 2012, 2:01:56 PM5/13/12
to rogue...@googlegroups.com
I'm new to Rogue and relatively new to Scala.

I'm confused by a compilation error I'm seeing related DateTimeField. I'm not sure what's going on. This code


class FooBar extends BsonRecord[FooBar] {
def meta = FooBar
object foo extends StringField(this, 100)
object bar extends DateTimeField(this)
}

object FooBar extends FooBar with BsonMetaRecord[FooBar] {
def baz: FooBar = {
val r: FooBar = FooBar.createRecord.foo("abc").bar(new DateTime())
return r
}
}


Generates this error:

[error]  type mismatch;
[error]  found   : Any
[error]  required: api.model.FooBar
[error] val r: FooBar = FooBar.createRecord.foo("abc").bar(new DateTime())
[error]                                                  ^

When I change the line to

val r: FooBar = FooBar.createRecord.bar(new DateTime()).foo("abc")

I get

[error] value foo is not a member of Any
[error] val r: FooBar = FooBar.createRecord.bar(new DateTime()).foo("abc")
[error]                                                        ^

I'm at loss what's going on here. Thanks in advance for any help.

Daniel

Jason Liszka

unread,
May 13, 2012, 2:28:19 PM5/13/12
to rogue...@googlegroups.com
Is your DateTime a org.joda.time.DateTime? I believe DateTimeField wants a java.util.Date, so try

.bar(new DateTime().toDate)

Daniel Eggert

unread,
May 14, 2012, 3:54:36 AM5/14/12
to rogue...@googlegroups.com
Sadly that doesn't help. Somehow FooBar.createRecord.bar(new DateTime().toDate) returns an "Any":

[error] /Users/deggert/Projects/Umzugsagenten/webserver/app/api/model/User.scala:36: value foo is not a member of Any
[error] val r: FooBar = FooBar.createRecord.bar(new DateTime().toDate).foo("abc")
[error]                                                               ^

/Daniel

On Sunday, May 13, 2012 8:28:19 PM UTC+2, Jason Liszka wrote:
Is your DateTime a org.joda.time.DateTime? I believe DateTimeField wants a java.util.Date, so try

.bar(new DateTime().toDate)

Jason Liszka

unread,
May 14, 2012, 9:53:44 AM5/14/12
to rogue...@googlegroups.com
What package is DateTimeField from?

This is really a lift-specific issue, you could try asking on the lift mailing list too if you want.

Daniel Eggert

unread,
May 14, 2012, 10:43:39 AM5/14/12
to rogue...@googlegroups.com
Yes, I figured it out. This was lift-specific and related to a mess with my import statements.

Thanks for the help!

/Daniel


On Monday, May 14, 2012 3:53:44 PM UTC+2, Jason Liszka wrote:
What package is DateTimeField from?

This is really a lift-specific issue, you could try asking on the lift mailing list too if you want.

Daniel Eggert

unread,
May 21, 2012, 9:44:56 AM5/21/12
to rogue...@googlegroups.com
And I had to switch to using toGregorianCalendar like so

    val l = LogEntry.createRecord.text(value).date(new DateTime().toGregorianCalendar)


/Daniel
Reply all
Reply to author
Forward
0 new messages