1. 程式人生 > >scala獲取當前時間戳和今天0時時間戳(精確到秒)的小工具

scala獲取當前時間戳和今天0時時間戳(精確到秒)的小工具

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