I have a data frame with a column of unix timestamp(eg.1435655706000), and I want to convert it to data with format 'yyyy-MM-DD', I've tried nscala-time but it doesn't work.
val time_col = sqlc.sql("select ts from mr").map(_(0).toString.toDateTime)
time_col.collect().foreach(println)
and I got error: java.lang.IllegalArgumentException: Invalid format: "1435655706000" is malformed at "6000"
What you can do is:
where time is a new column name and COL_WITH_UNIX_TIME is the name of the column which you want to convert. This will give data in millis, making your data more accurate, like:
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"