解决时分秒不能写入Date类型字段中

CallableStatement cstmt = null;
cstmt=conn.prepareCall("{call write_vehicle_tempplate(?)}");
cstmt.setString(1,temp.elementText("HPHM"));
cstmt.setTimestamp(2,getTimestamp(temp.elementText("DJRQ")));


Java代码
public static Timestamp getTimestamp(String s){
if(s==null||s.equals(""))
{
return null;
}
Timestamp timestamp=null;
try
{
if(s.length()>19)
{
s=s.substring(0,19);
}

SimpleDateFormat bartDateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

java.util.Date date = bartDateFormat.parse(s);

timestamp= new Timestamp(date.getTime());

} catch (ParseException e)
{
e.printStackTrace();
}

return timestamp;
}

你可能感兴趣的:(Date)