当前位置: 代码迷 >> Eclipse >> 请问怎么返回系统时间到字符串类型用于传递给SQL,datetime类型
  详细解决方案

请问怎么返回系统时间到字符串类型用于传递给SQL,datetime类型

热度:41   发布时间:2016-04-23 00:59:47.0
请教如何返回系统时间到字符串类型用于传递给SQL,datetime类型
获取系统当前时间gettime成字符串"yyyy-MM-dd HH:mm:ss.SSS"放到SQL里的datetime类型中应该怎样写呢
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

bartDateFormat = getTime().tostring();

不行呀,应该怎样写?

------解决方案--------------------
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中有 cast 函数
 
  相关解决方案