如何在Scala中重新创buildExcel的Longtypesdatetypes转换

我做了一个特殊的粘贴date列作为Excel中的值。 我想把结果长的值转换回spark的date(使用scala api)。

Example: converting 41088.96389 to date in excel results in 6/29/16 23:08 same when did through cast(DataTypes.TimestampType) in spark, it gives 01 Jan 1970 11:24:48 GMT

任何链接到Excel如何处理长types时转换date将不胜感激。

Excel的数字是自1900年1月1日以来经过的天数DateTimeDate通常接受一个UNIX历元时间戳,即自1970年1月1日以来经过的毫秒数(有时秒数取决于实现)。

两者之间的转换不是那么容易,因为你必须计算闰年,甚至时区。

你可以find不同的语言的多个实现,也许你可以移植其中的一个:

https://gist.github.com/peter216/6361201

https://gist.github.com/christopherscott/2782634

或者,也许只是尝试正常化Excel输出,如果您有权访问该工作表: https : //stackoverflow.com/a/11140924/1395437