a为TIME OBJECT用 a.toString()  就可以返回 JDBC time 格式或者把日期分别取出来String timeString=new String(a.getYear()+"-"+a.getMonth()+"-"+a.getDay())

解决方案 »

  1.   

    new SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());
      

  2.   

    new SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());
      

  3.   

    import java.text.*;
    import java.util.*;  Date date = new Date();
      
      new SimpleDateFormat("yyyy-MM-dd").format(date);
      
      

  4.   

    Format fmtDate = new SimpleDateFormat("yyyy-MM-dd");
    java.util.Date curDate = new java.util.Date();
    String strDate = fmtDate.format (curDate);
      

  5.   

    需要引入这两个包
    import java.text.*;
    import java.util.*;  Date date = new Date();
      
    SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
    format.format(date);就可以了.
      

  6.   

    /**
     * @author udate <a href="mailto:[email protected]">zgmg</a>
     * @version 1.0
     * @create time 2004-8-12
     **/
        public int compare(String formatStr,String a,String b){
            SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
                                                     //("hh:mm:ss");//时分秒
            Date o1 = null;
            Date o2 = null;
            long n1 = 0l,n2 =0l;
            try {
                o1 = sdf.parse(a);
                o2 = sdf.parse(b);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if(o1 != null){
                n1 = o1.getTime();
            }
            if(o2 != null){
                n2 = o2.getTime();
            }
            if (n1 < n2) {
                return -1;
            } else if (n1 > n2) {
                return 1;
            } else {
                return 0;
            }
        }
      

  7.   

    这样吧!
    GregorianCalendar currTime=new GregorianCalendar();
    cuTime=currTime.get(currTime.YEAR)+"-"+currTime.get(currTime.MONTH)+"-"+currTime.get(currTime.DATE);
      

  8.   

    import java.text.SimpleDateFormat;
    import java.util.Date;
    然后在程序里
    Date now=new Date();
    SimpleDataFormat sdf=new SimpleDataFormat("yyyy-MM-dd");
    String newDate=sdf.format(now);
    newDate就是2004-08-16
      

  9.   

    我觉得, heibai520(Crazy Java) 的方法更容易理解一些,不过有一个小疏忽 :-)currTime.get(currTime.MONTH) 应该为 (currTime.get(currTime.MONTH)+1)。
    因为在JAVA中0表示一月。改进后的方法为:
    GregorianCalendar currTime=new GregorianCalendar();
    cuTime=currTime.get(currTime.YEAR)+"-"+currTime.get(currTime.MONTH)+"-"+currTime.get(currTime.DATE);heibai520(Crazy Java)兄 看如何?