主题:小弟是新来的菜鸟,以后请各位多关照!
初学jsp,很多地方没搞懂,
看书上写的
<%out.println(cal.get(Calendar.MONTH));%>月
显示出来,居然和现实少一个月份?
什么原因啊???
全部脚本是:
<%@ page import ="java.util.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>import</title>
<body>
<h1>ÏÖÔÚʱ¼ä</h1>
<%
Calendar cal=Calendar.getInstance();
%>
<%out.println(cal.get(Calendar.YEAR));%>Äê
<%out.println(cal.get(Calendar.MONTH));%>ÔÂ
<%out.println(cal.get(Calendar.DATE));%>ÈÕ
<%out.println(cal.get(Calendar.HOUR));%>µã
<%out.println(cal.get(Calendar.MINUTE));%>·Ö
<%out.println(cal.get(Calendar.SECOND));%>Ãë
</body>
</html>
看书上写的
<%out.println(cal.get(Calendar.MONTH));%>月
显示出来,居然和现实少一个月份?
什么原因啊???
全部脚本是:
<%@ page import ="java.util.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>import</title>
<body>
<h1>ÏÖÔÚʱ¼ä</h1>
<%
Calendar cal=Calendar.getInstance();
%>
<%out.println(cal.get(Calendar.YEAR));%>Äê
<%out.println(cal.get(Calendar.MONTH));%>ÔÂ
<%out.println(cal.get(Calendar.DATE));%>ÈÕ
<%out.println(cal.get(Calendar.HOUR));%>µã
<%out.println(cal.get(Calendar.MINUTE));%>·Ö
<%out.println(cal.get(Calendar.SECOND));%>Ãë
</body>
</html>