gpt4 book ai didi

java - Java/Scala 中 Spark-csv 的时间戳解析

转载 作者:行者123 更新时间:2023-11-30 02:49:44 24 4
gpt4 key购买 nike

我正在使用 Spark-csv 读取 CSV 文件,其中一列是时间戳,其值类似于

Aug-02-2016 04:12:03:232 PM (CEST)

当然这是相当不标准的,所以我必须使用spark-csv选项

dateFormat: specifies a string that indicates the date format to use writing dates or timestamps. Custom date formats follow the formats at java.text.SimpleDateFormat. This applies to both DateType and TimestampType. If no dateFormat is specified, then "yyyy-MM-dd HH:mm:ss.S".

如何指定此格式?

我试过了

'mm-dd-yyyy HH:mm:ss.S PM (CEST)' 

没有成功。

最佳答案

您应该引用SimpleDateFormat您可以指定的格式的文档。

就你而言,我认为它会是这样的:

String format = "MMM-dd-yyyy hh:mm:ss:SSS a (z)"

关于java - Java/Scala 中 Spark-csv 的时间戳解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39065413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com