MyUtil:时间字符串转时间戳

package util

import java.text.SimpleDateFormat

object tranTimeToLong {

  def main(args: Array[String]): Unit = {

    val tm = "20170801164432123"
    val a = tranTimeToLong(tm)
    println(a)
  }

  def tranTimeToLong(tm:String) :Long={
    val fm = new SimpleDateFormat("yyyyMMddHHmmssSSS")
    val dt = fm.parse(tm)
    val tim: Long = dt.getTime()
    tim
  }
}

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