convert epoch to datetime in Scala / Spark
问题 I'm converting String representing a DateTime to unix_time (epoch) using : def strToTime(x: String):Long = { DateTimeFormat. forPattern("YYYY-MM-dd HH:mm:ss").parseDateTime(x).getMillis()/1000 } to get a list of Long like this : .map( p=> List( strToTime(p(0) ) ) ) my question is - what is the easiest way to turn in backwards? something like: def timeToStr(x: Long):String = { x*1000L.toDateTime} that I could use on the above List(Long) I have read Convert seconds since epoch to joda DateTime