代码如下:
//获取系统时间
String nowtime=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(Calendar.getInstance().getTime());
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
java.util.Date m_time1 = sdf.parse(nowtime);
//java中的日期类型转换成日期类型 用Timestamp将java.util.Date()转换成数据库日期类型,精确到秒
java.sql.Timestamp m_time2 = new java.sql.Timestamp(m_time1.getTime());
ptmt.setTimestamp(4, m_time2);
//执行
ptmt.execute();
jsp:如何在后台获取系统时间并将时间保存到mysql,时间精确到秒
最新推荐文章于 2022-12-13 14:33:33 发布