public static String toMysqlDateStr(Date date){
if (date==null) return "NULL";
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sqlValueWithQuotas(sdf.format(date));
}
public static String sqlValueWithQuotas(Object obj){
if ( obj == null ) return "NULL";
String str = obj.toString();
str.replaceAll("'", "\\'");
str = '\''+str+'\'';
return str;
}
Wednesday, June 18, 2008
Convert Date object to Mysql Date Format
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment