Scala 获取当前时间

  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
  }

   
executeUpdate("UPDATE message SET send_state=?,send_time=? WHERE message_id=?" , (stmt)=>{ stmt.setInt(1,2) stmt.setString(2,NowDate()) stmt.setInt(3,messageId) })

executeUpdate("UPDATE message SET send_state=?,send_time=NOW() WHERE message_id=?" , (stmt)=>{
      stmt.setInt(1,2)
      stmt.setInt(2,messageId)
    })
这里NOW() 和 NowDate() 效果一样
posted @ 2017-06-03 13:27  soyosuyang  阅读(20153)  评论(0编辑  收藏  举报