即:继承关系:java.lang.Object --》 java.util.Date --》 java.sql.Date
java.sql.
Date
转为java.util.
Date
java.sql.
Date
date
=new java.sql.
Date
();
java.util.
Date
d=new java.util.
Date
(
date
.getTime());
java.util.
Date
转为java.sql.
Date
java.util.
Date
utilDate=new
Date
();
java.sql.
Date
sqlDate=new java.sql.
Date
(utilDate.getTime());
java.util.
Date
utilDate=new
Date
();
java.sql.
Date
sqlDate=new java.sql.
Date
(utilDate.getTime());
java.sql.
Time
sTime=new java.sql.
Time
(utilDate.getTime());
java.sql.
Timestamp
stp=new java.sql.
Timestamp
(utilDate.getTime());
SimpleDateFormat f=new SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss"
);
f.format(stp);
f.format(sTime);
f.format(sqlDate);
f.format(utilDate)
java.sql.
Date
sqlDate=java.sql.
Date
.valueOf(
" 2005-12-12"
);
utilDate=new java.util.
Date
(sqlDate.getTime());
import java.text.SimpleDateFormat;
import java.util.*;
java.util.
Date
date
= new java.util.
Date
();
sy1=new SimpleDateFormat(
"yyyyMMDD"
);
String dateFormat=sy1.format(
date
);
sy=new SimpleDateFormat(
"yyyy"
);
SimpleDateFormat sm=new SimpleDateFormat(
"MM"
);
SimpleDateFormat sd=new SimpleDateFormat(
"dd"
);
String syear=sy.format(
date
);
String smon=sm.format(
date
);
String sday=sd.format(
date
);