This is how my dataframe looks like at the moment
+------------+
| DATE |
+------------+
| 19931001|
| 19930404|
| 19930603|
| 19930805|
+------------+
I am trying to reformat this string value to yyyy-mm-dd hh:mm:ss.fff and keep it as a string not a date type or time stamp.
How would I do that using the withColumn method ?
First, I created this DF:
For date management we are going to use joda time Library (don't forget to join the joda-time.jar file)
Finally, apply the function to dataframe:
This answer still needs some work, me myself is new to spark, but it is getting the job done, I think!
Here is the solution using
UDF
andwithcolumn
, I have assumed that you have a string date field inDataframe
this should work. Another notice is the that
mm
gives minutes andMM
gives months, hope this help you.