75
社区成员




new Date().getTime() 和 System.currentTimeMillis() 都可以用来获取当前时间的时间戳,但是它们的用法和返回值略有不同。
new Date().getTime() 返回一个表示当前日期和时间的 Date 对象,但是它不能改变日期和时间,只能用于获取当前时间。
System.currentTimeMillis() 返回一个表示当前时间的 long 值,精度高于 new Date().getTime(),可以用于获取当前时间,并且可以用于对日期和时间进行修改。
原文链接:https://blog.csdn.net/weixin_50002038/article/details/126838200