往数据库中添加日期格式为年月日,如(20101208),jsp页面中怎么写。
mip版 关注:221 答案:3 悬赏:10
解决时间 2021-01-24 17:16
已解决
2021-01-24 09:53
我想得到当前时间。
最佳答案
2021-01-24 10:11
SimpleDateFormat template= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now= template.format(new java.util.Date());
%>
//时间格式是随便你调的 如果你只要20101208
SimpleDateFormat template= new SimpleDateFormat("yyyyMMdd HH:mm:ss");
String today = template.format(new java.util.Date()).substring(0,8);
%>
全部回答
1楼
2021-01-24 12:09
页面可以这么写
后台处理时可以转换成java.Sql.Date类型存到数据库中 。
在页面上直接用 new Date()就行了,可以尝试一下。
2楼
2021-01-24 10:30
<%@page import ="java.util.*,java.text.*"%>
<%
simpledateformat template= new simpledateformat("yyyy-mm-dd hh:mm:ss");
string now= template.format(new java.util.date());
%>
<input type="hidden" name="date" value="<%=now%>"/>
//时间格式是随便你调的 如果你只要20101208
<%
simpledateformat template= new simpledateformat("yyyymmdd hh:mm:ss");
string today = template.format(new java.util.date()).substring(0,8);
%>
<input type="hidden" name="date" value="<%=today %>"/>
我要举报
如果感觉以上信息为低俗/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
点此我要举报以上信息!
推荐资讯
大家都在看