<!doctype html public "-//w3c/dtd/HTML 4.0//en">
<html>
<!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved. -->
<head>
<title>JSP DATE EXAMPLE</title>
<%@ page import="java.util.Date" %>
</head>
<body bgcolor=#ffffff>
<font color=#DB1260>
<h1>JSP DATE</h1>
<h2>
<% response.setHeader("Refresh", "1"); %>
The current date is <%= new Date() %>.
</h2>
<font size=-1>
Copyright &copy; 1999-2000 by BEA Systems, Inc. All Rights Reserved.
</font>
</BODY>
</HTML>

解决方案 »

  1.   

    <%
    Date date1=new Date();
    String s1="";
    int iYear=0;
    int iMonth=0;
    int iDay=0;
    iYear=date1.getYear();
    iMonth=date1.getMonth();
    iDay=date1.getDay();
    s1=iYear.toString()+iMonth.toString()+iDay.toString();
    %>
    不过有个问题,如 2001年2月2号  则 字符串是:200122 。你需要再加控制语句。
    可能有更好的方法,我也不是很清楚。
      

  2.   

      <% Calendar thisMonth=Calendar.getInstance(); 
    String year=String.valueOf(thisMonth.get(Calendar.YEAR)); 
    int month=thisMonth.get(Calendar.MONTH); 
    month=month+1;
    String day=String.valueOf(thisMonth.get(Calendar.DATE)); 
    int hour=thisMonth.get(Calendar.HOUR_OF_DAY); 
    String stats="上午好";
    if(hour>=0&&hour<=6) stats="凌晨";
    if(hour>6&&hour<=12) stats="上午";
    if(hour>12&&hour<=18) stats="下午";
    if(hour>18&&hour<=24) stats="晚上";
    %>                
    <%=year+"年"+month+"月"+day+"日"+"    "+stats%>
      

  3.   

    Calendar 类找不到
    不知要import 什么
      

  4.   

    回blueuiki() 
    getDay()是取星期;
    年份要加1900
    月份加1