System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

System.currentTimeMillis() is obviously the most efficient since it does not even create an object, but new Date() is really just a thin wrapper about a long, so it is not far behind. Calendar, on the other hand, is relatively slow and very complex, since it has to deal with the considerably complexity and all the oddities that are inherent to dates and times (leap years, daylight savings, timezones, etc.).

System.currentTimeMillis的()显然是最有效的,因为它甚至不创建一个对象,

Date()仅仅是一个大约长的瘦包装器,所以它也不甘落后。

日历,是相对缓慢和非常复杂的,因为它有处理相当复杂和奇特,是固有的日期和时间(闰年,夏令时,时区等)

你可能感兴趣的:(getinstance)