每天记录一点点东西,算是备忘录吧:
实现String 类型时间的转换
public static java.sql.Timestamp getTimestamp(String sDate, String pattern )
{
if (pattern == null || pattern.trim().equals(""))
{
pattern = "yyyy-MM-dd hh:mm:ss";
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
java.sql.Timestamp date = null;
try{
date = util2Timestamp(sdf.parse(sDate));
}catch(Exception e){
e.printStackTrace();
}
return date;
}
public static java.sql.Timestamp util2Timestamp(java.util.Date date)
{
return new java.sql.Timestamp(date.getTime());
}
}