Friday, October 16, 2009

Convert Java Date to Mysql Date

Normal 0 21 false false false MicrosoftInternetExplorer4

public static String toMysqlDateStr(Date date){

if (date==null)

return "NULL";

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

return '\''+sdf.format(date)+'\'';

}

No comments: