def tranTimeToLong(tm:String) :Long={ val fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") val dt = fm.parse(tm) val aa = fm.format(dt) val tim: Long = dt.getTime()

时间戳转化为时间:

import java.text.SimpleDateFormat
import java.util.Date
object test {
  def main(args: Array[String]): Unit = {
    val tm = "1502036122000"
    val a = tranTimeToString(tm)
    println(a)
  def tranTimeToString(tm:String) :String={
    val fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    val tim = fm.format(new Date(tm.toLong))