读书人

请问怎么返回系统时间到字符串类型用于

发布时间: 2014-01-03 00:30:09 作者: rapoo

请教如何返回系统时间到字符串类型用于传递给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 函数

读书人网 >Eclipse开发

热点推荐