How to Transform Spark Dataframe column for HH:MM:SS:Ms to value in seconds?

Viewed 2898

I would like to transform a spark dataframe column from its value hour min seconds

E.g "01:12:17.8370000"

Would become 4337 s thanks for the comment.

or "00:00:39.0390000"

would become 39 s.

I have read this question but I am lost on how I can use this code to transform my spark dataframe column.

Convert HH:mm:ss in seconds

Something like this

df.withColumn("duration",col("duration")....)

I am using scala 2.10.5 and spark 1.6

Thank you

3 Answers
Related