I am reading call records from a file and converting them to columns in a dataframe. How can I convert a column with a string value, which is actually a timestamp in format "yyyymmddhhMMss" to a timestamp before saving that dataframe to hive table? I used below snippet but I get null value in the hive table. As I understand I have to specify format i.e., "yyyymmddhhMMss" in which string values exist. But not sure how to do that. I am using spark 2.1.1
val df2 = df.withColumn("originTimeStamp",$"originTimeStamp".cast("timestamp")