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

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