如何把时间写入数据库,时间格式是:年-月-日 时:分:秒 找到方法了,用pstmt.setTimestamp就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");Date currentTime = new Date();String dateString = fmt.format(currentTime);pstmt.setCurTime(2,dateString)这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值); 数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");Date currentTime = new Date();String dateString = fmt.format(currentTime);pstmt.setCurTime(2,dateString)这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值); 数据库表中对应时间的那个字段的类型设为varchar型(指mysql),设字段名为:curTime,然后在代码中用SimpleDateFormat fmt= new SimpleDateFormat("yyyy年MM月dd日hh时mm分ss秒");Date currentTime = new Date();String dateString = fmt.format(currentTime);pstmt.setCurTime(2,dateString)这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值); 解决了好,恭喜,setTimestamp是可以的 求java试题和逻辑题 JAVA新手寻求学习帮助 java.util.Date 如何设置GMT格式为GST? 高分求怎么访问当前WEB应用程序下的一个目录... 科学计数法 求教oracle监听器与jsp冲突 基础问题 关于apache+tomcat+struts的问题 求助,JNDI绑定问题?? 歌词和音乐同步问题?winnap的歌词插件基于什么样的原理做出来? tomcat6(窗口模式)正常,tomcat6w(服务模式)失败,二者有何区别呀? Pager-taglib分页如何传五个参数以上?
Date currentTime = new Date();
String dateString = fmt.format(currentTime);
pstmt.setCurTime(2,dateString)
这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);
Date currentTime = new Date();
String dateString = fmt.format(currentTime);
pstmt.setCurTime(2,dateString)
这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);
Date currentTime = new Date();
String dateString = fmt.format(currentTime);
pstmt.setCurTime(2,dateString)
这里我是套了你的写法,一般数据操作不是这样写的,而是用: 实体对象.set属性方法(字段值);