Date d = new Date();
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(tempDate.format(d));

解决方案 »

  1.   

    Date d = new Date();
    SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
    System.out.println(tempDate.format(d));
      

  2.   

    在写这个之前要先导包进去。如: java.util.*
      

  3.   

    jsp里用前面的代码加 <%=tempDate.format(d)=>
    100分啊,好多
      

  4.   

    包好象引错了,java.text.SimpleDateFormat,误倒人家
      

  5.   

    <SCRIPT>
    function Refresh()...{
     Time.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
     setTimeout("Refresh()",1000);
    }
    var timer=setTimeout("Refresh()",1000);
    </SCRIPT>
    <DIV style="background-color:#eeeeee" id="Time"></DIV>
    不过貌似structs有calendar标签可以直接拿的呀
      

  6.   

    不要用JS获取日期对象赋值,JS是获取的客户端的值
    struts里应该没有标签能够直接做到,在action里取到系统日期java.util.Date类型,在jsp上可以通过s:date标签来对其格式化。如:
    <s:date name="person.birthday" format="dd/MM/yyyy" />
      

  7.   

    qq技术群java jsp qun 
    27324553 (1群) 
    34894728 (2群) 
    18175454 (3群高级群) 
    60440677 (4群)
    装死误入 
      

  8.   


    // 取得系统時間
    Calendar rightNow = Calendar.getInstance();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    String sysdate = format.format(rightNow.getTime());
      

  9.   

    <%
    java.util.Date now = new java.util.Date()
    pageContext.setAttribute("now",now);
    %><s:date name="#attr.now" format="dd/MM/yyyy" nice="true"/>你可以在资源文件中配置
    struts.date.format=yyy年MM月dd日当然,你也可以在Action中声明一个
    String now;//get&set
    <s:date name="now" format="dd/MM/yyyy" nice="true"/>
      

  10.   

    // =============取系统时间start================
    Calendar cal = Calendar.getInstance();
    // -200代表200天前这个时候的时间
    cal.add(Calendar.DAY_OF_YEAR, -200);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    String nowtime = sdf.format(cal.getTime());
    // =============取系统时间end================
      

  11.   

    引用 1 楼 harryzyp 的回复:
    Date d = new Date(); 
    SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd"); 
    System.out.println(tempDate.format(d)); 
     
    这个不错!
      

  12.   

    不能用 JavaScript 赋值,JavaScript 只能获得客户端的时间。
      

  13.   

    <script language="javascript">
           function getTodayDate(){
       
          var todaydate = new Date();
          var curyear = todaydate.getYear();
          var curmonth = todaydate.getMonth()+1;
          var curday = todaydate.getDate();              //这里通过id进行显示
          document.getElementById("inputendyear").value = curyear;
          document.getElementById("inputendmonth").value = curmonth;
          document.getElementById("inputendday").value = curday;
          }</script>
      

  14.   

    应该是这样,上面的是我直接从代码里复制出来的,不合适
          document.getElementById("displaydate").innerHTML = curyear+"年"+curmonth +"月"+curday+"日";
          
      

  15.   

    Date d = new Date(); 
    SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd"); 
    System.out.println(tempDate.format(d));
      

  16.   

    晕前面已经很详细了
    就new一个date,再format一下
      

  17.   


    Date dt=new Date();
       SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
    需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!
      

  18.   


    Date dt=new Date();
       SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
    需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!
      

  19.   


    Date dt=new Date();
       SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
    需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!
      

  20.   

    在action里取到系统日期java.util.Date类型
      

  21.   

    自己写一个标签tag,调用一个static函数