datetime.jsp

来自「Web开发的基本框架」· JSP 代码 · 共 56 行

JSP
56
字号
<%@ taglib uri="/tags/web-date" prefix="date"%>
<%@ taglib uri="/tags/web-loushang" prefix="loushang"%>
<%@ taglib uri="/tags/web-i18n" prefix="web"%>
<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="org.loushang.web.taglib.util.skin.SkinUtils,java.util.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<web:js src="calendar.js"/>
<link rel="stylesheet" type="text/css" href="<%=SkinUtils.getCSS(request,"css-xp1.css")%>">
<%
Map map =new HashMap();
//取得当前日期
SimpleDateFormat format=
new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date=new Date();
String now=format.format(date);
map.put("time",now);
request.setAttribute("html.data",map);
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<table width="100%">
<tr>
<td><label class="title">年月日 时间 组件</label></td>
<% String file=request.getServletPath().substring(1);
   String app=request.getContextPath();
%>
<td><label class="title">url:<%=file%></label></td>
<td align="right" valign="bottom" nowrap>&nbsp;[<a href="<%=app%>/src.jsp?target=<%=file %>" target="source">源代码</a>]&nbsp;</td>
</tr>
</table>
<hr>
<body>
<tr>
<td width=40%><button name="test" onclick="test()" value="test">显示日期值</button>
</td>
</tr>
<form name=mainform method=post>
<div align="center">
  <center>
      <!--日期html开始-->
	<date:date name="date" property="time" divname="dateDiv" hastime="true" hasecond="true" sourceFormat="yyyy/MM/dd HH:mm:ss" targetFormat="yyyyMMdd HH:mm:ss" showLength="19">
	</date:date>
      <!--日期html结束-->
  </center>
</div>
</form>
</body>
</html>
<script language="javascript">
function test(){
	alert(dateDiv.getDateValue());
}
</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?