I have a Spark data frame (Scala API) which contains a column called transfer date, the dates are in string format and are in this format 24-JUL-17.
I want to convert it to date string into timestamp. How can I do it?
I have a Spark data frame (Scala API) which contains a column called transfer date, the dates are in string format and are in this format 24-JUL-17.
I want to convert it to date string into timestamp. How can I do it?
It can also be done with to_timestamp(date_col, expr)
import org.apache.spark.sql.functions.to_timestamp
val df = date.withColumn("ts", to_timestamp($"transfer date", "dd-MMM-yy"))
Now ts column in df is of timestamp type.