怎样读取一个文件 的日期?

newman0708 2003-04-24 10:56:35
Calendar tempDate = Calendar.getInstance() ;//new GregorianCalendar(); tempDate.setTimeInMillis(a[i].lastModified());
//tempDate.setTime(new Date(a[i].lastModified()));
String monthFile = ""+(tempDate.get(Calendar.MONTH)+1);
String dayFile = ""+tempDate.get(Calendar.DAY_OF_MONTH);
String yearFile = ""+(tempDate.get(Calendar.YEAR)+1900);//-2000
String hourFile = ""+tempDate.get(Calendar.HOUR_OF_DAY);//24-hour clock
String minuteFile=""+tempDate.get(Calendar.MINUTE);

我用这个 出现 错误!
...全文
51 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
helpall 2003-04-25
  • 打赏
  • 举报
回复
看一看你的JDK版本,setTimeInMillis()不是每个版本都有的.
用setTime(new Date(file.lastModified()));也是一样的.
newman0708 2003-04-25
  • 打赏
  • 举报
回复
File file;

好像是无法使用tempDate.setTimeInMillis(file.lastModified());

我要使用tempDate.setTimeInMillis(),获取一个文件的日期。
我该怎么办啊!
高手帮忙!
staminalim 2003-04-25
  • 打赏
  • 举报
回复
可以呀
newman0708 2003-04-25
  • 打赏
  • 举报
回复
java.lang.IllegalAccessError: try to access method java.util.Calendar.setTimeInM
illis(J)V from class internetwork.ftp.ftpSubServer
at internetwork.ftp.ftpSubServer.cmdLIST(FtpServer.java:330)
at internetwork.ftp.ftpSubServer.actionPerformedCommand(FtpServer.java:1
84)
at internetwork.ftp.ftpSubServer.run(FtpServer.java:150)
newman0708 2003-04-25
  • 打赏
  • 举报
回复
没有说什么错,就是不能运行(但是能编译通过)。
怪事!
cowboy1114 2003-04-25
  • 打赏
  • 举报
回复
我试了,没有问题啊?
可以把源代码全部都贴出来吗???
helpall 2003-04-24
  • 打赏
  • 举报
回复
什么错?

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧