我在jsp中显示时间的代码是:
new java.util.Date()
它在网页中显示的时间是:Wed Sep 28 13:55:25 JST 2005
我现在想格式化为:28-9-2005 13:55:25

解决方案 »

  1.   

    Date date = new Date();
    SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
    String s = simpledateformat.format(date);
      

  2.   

    java.text.DateFormat df = new java.text.SimpleDateFormat(dd-MM-yyyy HH:mm:ss);
    df.format(new java.util.Date());
      

  3.   

    public static void main(String[] args)
        {
         java.text.DateFormat df = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
    System.out.println(df.format(new java.util.Date()));
        }
      

  4.   

    SimpleDateFormat simpledateformat = new SimpleDateFormat("M-dd-yyyy HH:mm:ss");
      

  5.   

    SimpleDateFormat simpledateformat = new SimpleDateFormat("dd-M-yyyy HH:mm:ss");
      

  6.   

    在JSP文件开头写上
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>然后用时间的时候可以这样
    date = new java.util.Date();
    <fmt:dateFormat pattern="yyyy-mm-dd" value="${date}">
    大体是这样的,具体语法我记不清了