我想将字符串对象转换成时间对象:
String publishtime=request.getParameter("Publish_time");
Comment c=new Comment();c.setPublishTime(DateFormat.parse(publishtime));DataAccess da=new DataAccess();
da.insertComment(c);
在eclipse里面报这样的错:Multiple ers at this line
Cannot make a static reference to the non-static method parse(String) from the type DateFormat
The methed setPublicTime(Date) in the type Comment is not applicable for the arguments (Date)
String publishtime=request.getParameter("Publish_time");
Comment c=new Comment();c.setPublishTime(DateFormat.parse(publishtime));DataAccess da=new DataAccess();
da.insertComment(c);
在eclipse里面报这样的错:Multiple ers at this line
Cannot make a static reference to the non-static method parse(String) from the type DateFormat
The methed setPublicTime(Date) in the type Comment is not applicable for the arguments (Date)
String str = "2006-09-07 08:00:00";
SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
myFmt.parse(str);
} catch (ParseException p) {}