Scala中日期类型的数据

三世轮回 提交于 2019-12-10 16:46:18
import java.text.SimpleDateFormat

object TimeStampTest {

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

    // 获取系统的时间戳
    val tsLong = System.currentTimeMillis()
    //println(tsLong) // 1575871214234

    // 根据获取的时间戳 计算系统的时间
    val sdf0 = new SimpleDateFormat("HH:mm:ss").format(tsLong)
    //println(sdf0) // 14:00:14


    // 代码调试
    val sdf1 = new SimpleDateFormat("HH:mm:ss").format(1575871214234L)
    println(sdf1) // 14:00:14

    val sdf2 = new SimpleDateFormat("HH:mm:ss").format(1575871214000L)
    println(sdf2) // 14:00:14

    // 代码调试
   val sdf3 = new SimpleDateFormat("HH:mm:ss").format(1575871540720L)
    println(sdf3) // 14:05:40

    val sdf4 = new SimpleDateFormat("HH:mm:ss").format(1575871540000L)
    println(sdf4) // 14:05:40

  }

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!