MyUtil:时间戳转成时间字符串

import java.text.SimpleDateFormat
import java.util.Date

object tranTimeToString {

  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))
    tim
  }
}

你可能感兴趣的:(#,MyUtil)