我需要转换 Tue Jul 07 2020 12:30:42 用scala为spark加时间戳。因此,预期结果将是: 2020-07-07 12:30:42 你知道怎么做吗?
Tue Jul 07 2020 12:30:42
2020-07-07 12:30:42
14ifxucb1#
你可以用 to_timestamp 功能。
to_timestamp
spark.conf.set("spark.sql.legacy.timeParserPolicy", "LEGACY") <-- Spark 3.0 Only. df.withColumn("date", to_timestamp('string, "E MMM dd yyyy HH:mm:ss")) .show(false) +------------------------+-------------------+ |string |date | +------------------------+-------------------+ |Tue Jul 07 2020 12:30:42|2020-07-07 12:30:42| +------------------------+-------------------+
1条答案
按热度按时间14ifxucb1#
你可以用
to_timestamp
功能。