构造一个时间类 并用SimpleDateFormat输出 为什么最后两行是错的 麻烦高手帮忙改一下 谢谢了

[复制链接]
查看11 | 回复1 | 2011-5-17 04:39:59 | 显示全部楼层 |阅读模式
importjava.text.SimpleDateFormat;


publicclassfirst{

        /**
        *@paramargs
        */
       
        publicclassMydate
        {
                intyear;
                intmonth;
                intday;
                inthour;
                intminute;
                intsecond;
                publicMydate(intyear,intmonth,intday,inthour,intminute,intsecond)
                {
                        this.year=year;
                        this.month=month;
                        this.day=day;
                        this.hour=hour;
                        this.minute=minute;
                        this.second=second;
                }
                publicintgetyear(){
                        returnyear;
                }
                publicintgetmonth(){
                        returnmonth;
                }
                publicintgetdate(){
                        returnday;
                }
                publicintgethour(){
                        returnhour;
                }
                publicintgetminute(){
                        returnminute;
                }
                publicintgetsecond(){
                        returnsecond;
                }
        }
        publicstaticvoidmain(String[]args){
                //TODOAuto-generatedmethodstub
                SimpleDateFormatbartDateFormat=newSimpleDateFormat(\"MM-dd-yyyy\");
                //CreateadateformatterthatparsedatesoftheformMM-dd-yyyy
                StringdateStringToParse=\"05-01-2011\";
                //Createastringcontainingatextdatetobeparsed
               
                Mydated1=newMydate();
                d1=Mydate(3,2,4,0,0,0);
        }

}
回复

使用道具 举报

千问 | 2011-5-17 04:39:59 | 显示全部楼层
Mydated1=newMydate();
d1=Mydate(3,2,4,0,0,0);
要改成Mydated1=newMydate(3,2,4,0,0,0);
Mydate()没有这个构造函数,即使有後面这个d1=Mydate(3,2,4,0,0,0);
也错了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行