日期:2014-05-17 浏览次数:20880 次
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String temp = rs.getString(3);
Date date = sd.parse(temp);
------解决方案--------------------
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = sd.parse("2009-08-05 17:36:00");
------解决方案--------------------
如果你数据库中时date型,
String temp = rs.getString(3); 改成rs.getDate(3)
如果数据库中是varchar
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class test {
public static void main(String[] args) throws Exception {
DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
String s = "1987-10-10";
Date date = fmt.parse(s);
System.out.println(fmt.format(date));
}
}
------解决方案--------------------
SimpleDateFormat