<%@ page import="java.util.Date" import="java.text.SimpleDateFormat"%>
<% m_date = new Date();
SimpleDateFormat smpDateFormat=new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
String buf=smpDateFormat.format(m_date);
%>

解决方案 »

  1.   

    刚才又试了一次,居然成了:2003-21-03 11:21:31 。我是从ASP转来学JSP的,真的有点晕了,希望高手指点一下。
      

  2.   

    SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
    改成
    SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      

  3.   

    out.println((new Date()).toLocaleString());
      

  4.   

    Date  date = new Date();
    Locale  locale = new  Locale("zh","cn","");
    DateFormat  type = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM,locale);
    String datetime=type.format(date);取程序所在机器系统时间,将MEDIUM可改为LONG或SHORT将得到不同的格式
      

  5.   

    然后用string.substring来处理一下就可以了