今天改一个程序,需要把一个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