static Calendar calendar = Calendar.getInstance();
----------------------------public static java.sql.Timestamp StringToTimeStamp(String rq) {
if(rq.length()==0) return null;
int yy=1900;
int MM=1;
int dd=1;
int hh=0;
int mm=0;
int ss=0;
try {
yy = Mc.strToInt(rq.substring(0, 4));//Mc.strToInt()是自编转换函数
MM = Mc.strToInt(rq.substring(5, 7));
dd = Mc.strToInt(rq.substring(8, 10));
hh = Mc.strToInt(rq.substring(11, 13));
mm = Mc.strToInt(rq.substring(14, 16));
}catch(java.lang.Exception e){
    if (yy==1900) return null;
}
calendar.set(yy,MM-1,dd,hh,mm,ss);
java.sql.Timestamp dt=new java.sql.Timestamp(calendar.getTime().getTime());
return dt;
}

解决方案 »

  1.   

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
            try {
                Date date=sdf.parse("2003年12月1日 22:22:01");
            } catch (ParseException e) {
                e.printStackTrace();  //To change body of catch statement use Options | File Templates.
            }