现在日期=新日期();
if (now.getTime() - leasedDate.getTime() > 21 * 1000 * 60 * 60 * 24)
throw new TooLate();
leased.remove(x);
Run Code Online (Sandbox Code Playgroud)
我正在看一些代码示例,上面是它的一部分.有些事情我不明白.名为"now"的日期对象是否包含当前日期和小时?因为我认为它在初始化时应该是空的,所以我不明白now.getTime()是如何工作的.
谢谢!
Pet*_*hev 11
来自Java Docs的报价 - new Date() - Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
所以你的问题的答案是:是的,它包含当前日期.
| 归档时间: |
|
| 查看次数: |
2505 次 |
| 最近记录: |