在jsp文件顶部加上
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*,java.text.*" errorPage="" %>
定义变量获取当前系统时间
String Nowtime=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
存入数据库
String sqlinsert="insert into Resource(ResPubTime) values(Nowtime)";
记得读取日期要用getDate(ResPubTime),如果用getString(ResPubTime)那么是日期和时间都会出来,要只获得时间这个我没试过。不知道是不是getTime()。
温馨提示:答案为网友推荐,仅供参考