The constructor Date() is undefined

The constructor Date() is undefined

  

      今天改一個程序,需要把一個Date型的字段轉爲String型的,代碼如下:

 

   DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Date date = new Date();     //錯誤提示The constructor Date() is undefined
   String endTimee = format.format(date);

 

     原因是我引進的是import java.sql.Date,其實應該是import java.util.Date

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章