I have the following model:
class Recording private() extends MongoRecord[Recording] with ObjectIdPk[Recording] {
def meta = Recording
object time extends IntField(this)
object fulltime extends IntField(this)
}
When I do the following:
var time = System.currentTimeMillis() / 1000
var fulltime = System.currentTimeMillis()
Recording.createRecord.
time(time.toInt).
fulltime(fulltime.toInt).
save
The field “time” is correctly stored as “1334919100”, but the “fulltime” field is saved as “-815728745”, whats going on here? Is there something I need to do for it to accept a timestamp in full milisecond length?
Any help is much appreciated, thanks in advance 🙂
System.currentTimeMillisreturns aLong. You are only lucky that it works in thetimecase. Infulltimeyou are experiencing an integer overflow. (This already happens in thetoIntcall.) ChooseLongFieldfor both objects.