Spark中统计程序运行时间

import java.text.SimpleDateFormat
import java.util.Date
  
     val s=NowDate()      //显示当前的具体时间
    val now=new Date()

     {
        你的Spark程序........
      }
 
      val now2: Date=new Date()

   val now3=now2.getTime -now.getTime

    val dateFormat: SimpleDateFormat = new SimpleDateFormat("mm:ss")

    val date = dateFormat.format(now3)   //此为获取到的时间差

 def NowDate(): String = {
    val now: Date = new Date()
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    val date = dateFormat.format(now)
    return date

  }

结果:

NowDate:结果类似为:2017-10-12 20:14:57
14:57
15:03
00:06   (差值结果)

posted @ 2017-10-12 20:24  soyosuyang  阅读(3743)  评论(0编辑  收藏  举报