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   (差值结果)

相关文章:

  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2021-09-05
  • 2021-11-05
  • 2021-12-15
  • 2022-12-23
  • 2021-12-15
  • 2021-09-11
  • 2021-12-03
相关资源
相似解决方案