2014年1月2日星期四

Advice on how to return the system time to a string type used to pass to SQL, datetime type

Get the current system time gettime a string "yyyy-MM-dd HH: mm: ss.SSS" into SQL datetime type in the how to write it
SimpleDateFormat bartDateFormat = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss.SSS");

bartDateFormat = getTime () tostring ().;

not to die , how to write ?
------ Solution ---------------------------------------- ----
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String time= bartDateFormat.format(Calendar.getInstance().getTime());
System.out.println(time);
 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));


sql has cast function

------ For reference only -------------------------------- -------
write separately , finished in a combined into sql time format to try

没有评论:

发表评论