且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Scala/Spark中将纪元转换为日期时间

更新时间:2023-02-03 16:37:24

您有一个优先级问题-在应用*之前将.toDateTime应用于1000L.用括号括起来以清楚显示呼叫顺序:

You have a precedence problem - .toDateTime is being applied to 1000L before * is applied. Bracket the operations to make the call order clear:

def timeToStr(x: Long): String = { (x*1000L).toDateTime }