如何使用nscala时间生成随机日期时间

如何使用nscala时间生成随机日期时间,scala,Scala,我需要用nscala时间生成随机日期时间 我找到了,为了乔达蒂姆。不过,我还没有把答案翻译成nscala 以下是我想做的: import com.github.nscala_time.time.Imports._ val startTimestamp = DateTime(Random.nextLong(1000)) val endTimestamp = DateTime(Random.nextLong(1000) + 1000) 问题是,在nscala-time中,DateTime的伴生对象

我需要用nscala时间生成随机日期时间

我找到了,为了乔达蒂姆。不过,我还没有把答案翻译成nscala

以下是我想做的:

import com.github.nscala_time.time.Imports._
val startTimestamp = DateTime(Random.nextLong(1000))
val endTimestamp = DateTime(Random.nextLong(1000) + 1000)
问题是,在nscala-time中,DateTime的伴生对象不公开任何
apply
方法


顺便问一下:您是否建议为Scala使用另一个时间框架?

只需在这个框架上绕过nscala时间,并使用
new
关键字:

val startTimestamp = new DateTime(Random.nextLong(1000))
val endTimestamp = new DateTime(Random.nextLong(1000) + 1000)
返回类型相同