展开全部
数据库里面的datetime对应java里面的:java.util.Date
java.util.Date包含日期
java.util.Time包含时间
java.util.Timestamp包含日期和62616964757a686964616fe58685e5aeb931333361323031时间
publicclassSqlDateTime{
publicstaticvoidmain(String[]args){
java.util.DatejavaDate=newjava.util.Date();
longjavaTime=javaDate.getTime();
System.out.println(“TheJavaDateis:”+javaDate.toString());
java.sql.DatesqlDate=newjava.sql.Date(javaTime);
System.out.println(“TheSQLDATEis:”+sqlDate.toString());
java.sql.TimesqlTime=newjava.sql.Time(javaTime);
System.out.println(“TheSQLTIMEis:”+sqlTime.toString());
java.sql.TimestampsqlTimestamp=newjava.sql.Timestamp(javaTime);
System.out.println(“TheSQLTIMESTAMPis:”+sqlTimestamp.toString());
}
}