读书人

new 一个 Date用 eclipse 输出如何

发布时间: 2012-09-02 21:00:34 作者: rapoo

new 一个 Date,用 eclipse 输出,怎么有错误呢

Java code
public class CloneTest{    public static void main(String[] args)    {        Date d = new Date();        System.out.println(  d.toString() );            }}


上面代码,如果按 Ctrl + F11 运行就没问题。如果按F11,那调试窗口输出下面的东西


Java code
CloneTest [Java 应用程序]        本地主机 52205 处的 CloneTest            线程 [main](已暂挂(异常 FileNotFoundException))                FileInputStream.open(String) 行: 不可用 [本机方法]                FileInputStream.<init>(File) 行: 不可用                ZoneInfoFile$1.run() 行: 不可用                AccessController.doPrivileged(PrivilegedExceptionAction<T>) 行: 不可用 [本机方法]                ZoneInfoFile.readZoneInfoFile(String) 行: 不可用                ZoneInfoFile.createZoneInfo(String) 行: 不可用                ZoneInfoFile.getZoneInfo(String) 行: 不可用                ZoneInfo.getTimeZone(String) 行: 不可用                TimeZone.getTimeZone(String, boolean) 行: 不可用                TimeZone.setDefaultZone() 行: 不可用                TimeZone.getDefaultRef() 行: 不可用                Date.normalize() 行: 不可用                Date.toString() 行: 不可用                String.valueOf(Object) 行: 不可用                PrintStream.println(Object) 行: 不可用                CloneTest.main(String[]) 行: 11        D:\JDK\bin\javaw.exe(2012-7-26 下午02:49:47)    CloneTest [Java 应用程序]        本地主机 52216 处的 CloneTest            线程 [main](已暂挂(异常 FileNotFoundException))                FileInputStream.open(String) 行: 不可用 [本机方法]                FileInputStream.<init>(File) 行: 不可用                ZoneInfoFile$1.run() 行: 不可用                AccessController.doPrivileged(PrivilegedExceptionAction<T>) 行: 不可用 [本机方法]                ZoneInfoFile.readZoneInfoFile(String) 行: 不可用                ZoneInfoFile.createZoneInfo(String) 行: 不可用                ZoneInfoFile.getZoneInfo(String) 行: 不可用                ZoneInfo.getTimeZone(String) 行: 不可用                TimeZone.getTimeZone(String, boolean) 行: 不可用                TimeZone.setDefaultZone() 行: 不可用                TimeZone.getDefaultRef() 行: 不可用                Date.normalize() 行: 不可用                Date.toString() 行: 不可用                <旧方法,位于><未知声明类型>>        D:\JDK\bin\javaw.exe(2012-7-26 下午02:51:33)    CloneTest [Java 应用程序]        本地主机 52223 处的 CloneTest            线程 [main](已暂挂(异常 FileNotFoundException))                FileInputStream.open(String) 行: 不可用 [本机方法]                FileInputStream.<init>(File) 行: 不可用                ZoneInfoFile$1.run() 行: 不可用                AccessController.doPrivileged(PrivilegedExceptionAction<T>) 行: 不可用 [本机方法]                ZoneInfoFile.readZoneInfoFile(String) 行: 不可用                ZoneInfoFile.createZoneInfo(String) 行: 不可用                ZoneInfoFile.getZoneInfo(String) 行: 不可用                ZoneInfo.getTimeZone(String) 行: 不可用                TimeZone.getTimeZone(String, boolean) 行: 不可用                TimeZone.setDefaultZone() 行: 不可用                TimeZone.getDefaultRef() 行: 不可用                Date.normalize() 行: 不可用                Date.toString() 行: 不可用                CloneTest.main(String[]) 行: 11        D:\JDK\bin\javaw.exe(2012-7-26 下午02:52:45)    CloneTest [Java 应用程序]        本地主机 52344 处的 CloneTest            线程 [main](已暂挂(异常 FileNotFoundException))                FileInputStream.open(String) 行: 不可用 [本机方法]                FileInputStream.<init>(File) 行: 不可用                ZoneInfoFile$1.run() 行: 不可用                AccessController.doPrivileged(PrivilegedExceptionAction<T>) 行: 不可用 [本机方法]                ZoneInfoFile.readZoneInfoFile(String) 行: 不可用                ZoneInfoFile.createZoneInfo(String) 行: 不可用                ZoneInfoFile.getZoneInfo(String) 行: 不可用                ZoneInfo.getTimeZone(String) 行: 不可用                TimeZone.getTimeZone(String, boolean) 行: 不可用                TimeZone.setDefaultZone() 行: 不可用                TimeZone.getDefaultRef() 行: 不可用                Date.normalize() 行: 不可用                Date.toString() 行: 不可用                CloneTest.main(String[]) 行: 11        D:\JDK\bin\javaw.exe(2012-7-26 下午02:57:42)     



[解决办法]
编译是通不过的啊。
我机器只有jdk 所以我编译了下你写的 根本就编译不过去。

[解决办法]
刚才忘了引包了 哈哈

Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyy-yy-yy");
String birthday = df.format(date);
[解决办法]
Java code
package a;import java.util.Date;public class CloneTest{    public static void main(String[] args)    {        Date d = new Date();        System.out.println(  d.toString() );//System.out.println(  d );//一样效果            }}
[解决办法]
没有问题的啊
[解决办法]
正解, 好像就是少了import java.util.Date;

探讨

Java code
package a;

import java.util.Date;

public class CloneTest
{
public static void main(String[] args)
{
Date d = new Date();
System.out.println( d.toString() );//Sys……

[解决办法]
悲催的楼主是eclipse的问题。
你还是用myeclipse吧。

[解决办法]
楼主导入包了吗

读书人网 >J2SE开发

热点推荐