一.时间戳转化为日期格式:
val time="1622457251089" //TODO 时间转换函数:时间戳 1622457251089 def replaceTime1(tm:String) :String= { import java.text.SimpleDateFormat val sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") val format: String = sf.format(new Date(Long.parseLong(time))) format } println("转化后的时间是:"+replaceTime1(time))
二.带时区的格式:2021-04-27T11:34:52+08:00
import org.apache.spark.sql.functions.udf //TODO 时间格式转换函数 2021-04-27T11:34:52+08:00 def replaceTime1(tm:String) :String= { val t1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX") val t2 = new SimpleDateFo