ddate=new date()和ddate=new date(iyear,imonth,0)
不同的构造函数,都是构造了一个date实例,就是他们的表现形式不同,你可以打出来看一下。ddate=new date(iyear,imonth,0)这个将日期格式化了。

解决方案 »

  1.   

    ddate=new date()//表示获得当前日期
    ddate=new date(iyear,imonth,0)//表示获得指定的日期(年,月,日)
      

  2.   

    /**
         * Allocates a <code>Date</code> object and initializes it so that 
         * it represents the time at which it was allocated, measured to the 
         * nearest millisecond. 
         *
         * @see     java.lang.System#currentTimeMillis()
         */
        public Date() {
            this(System.currentTimeMillis());
        }
        /**
         * Allocates a <code>Date</code> object and initializes it so that 
         * it represents midnight, local time, at the beginning of the day 
         * specified by the <code>year</code>, <code>month</code>, and 
         * <code>date</code> arguments. 
         *
         * @param   year    the year minus 1900.
         * @param   month   the month between 0-11.
         * @param   date    the day of the month between 1-31.
         * @see     java.util.Calendar
         * @deprecated As of JDK version 1.1,
         * replaced by <code>Calendar.set(year + 1900, month, date)</code>
         * or <code>GregorianCalendar(year + 1900, month, date)</code>.
         */
        public Date(int year, int month, int date) {
            this(year, month, date, 0, 0, 0);
        }