scala获取当前时间戳和今天0时时间戳(精确到秒)的小工具

时间:2021-08-14 02:20:55
package com.unicom

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

/**
  * Created by Administrator on 2016/10/21.
  */
object TimeUtils {
  val now = new Date()
  def getCurrent_time(): Long = {
        val a = now.getTime
        var str = a+""
        str.substring(0,10).toLong
  }
  def getZero_time():Long={
      val dateFormat = new SimpleDateFormat("yyyy-MM-dd")
      val a = dateFormat.parse(dateFormat.format(now)).getTime
      var str = a+""
      str.substring(0,10).toLong
  }
}