import java.util.Date;class DateTimeDisplay
{ Date today;
DateTimeDisplay()
{
today=new Date();
}
void display()
{
String strDate;
// String strTime;
strTime="";
System.out.println("今天的日期是:"+today);
long time=today.getTime();
System.out.println("自1970年1月1日起"+"以毫秒为单位的时间(GMT):"+time);
strDate=today.toString();
//提取GMT时间
strTime=strDate.substring(11,(strDate.length()-4));
//按小时,分钟和秒提取时间
strTime="时间:"+strTime.substring(0,8);
System.out.println(strTime);
}
public static void main(String [] args)
{
DateTimeDisplay today=new DateTimeDisplay();
today.display();
}
}谁帮我看下哪不对,怎么改,好像是 strTime="";和 strTime="时间:"+strTime.substring(0,8);这几个地方有问题
{ Date today;
DateTimeDisplay()
{
today=new Date();
}
void display()
{
String strDate;
// String strTime;
strTime="";
System.out.println("今天的日期是:"+today);
long time=today.getTime();
System.out.println("自1970年1月1日起"+"以毫秒为单位的时间(GMT):"+time);
strDate=today.toString();
//提取GMT时间
strTime=strDate.substring(11,(strDate.length()-4));
//按小时,分钟和秒提取时间
strTime="时间:"+strTime.substring(0,8);
System.out.println(strTime);
}
public static void main(String [] args)
{
DateTimeDisplay today=new DateTimeDisplay();
today.display();
}
}谁帮我看下哪不对,怎么改,好像是 strTime="";和 strTime="时间:"+strTime.substring(0,8);这几个地方有问题
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货