Catalogue [-]
- One, the unit conversion of time
- Second, System.currenttimemillis () calculation method
One, the unit conversion of time
1 seconds =1000 milliseconds (ms) 1 msec =1/1,000 sec (s)
1 sec =1,000,000 microseconds (μs) 1 μs =1/1,000,000 sec (s)
1 sec =1,000,000,000 ns 1 nanoseconds =1/1,000,000,000 sec (s)
1 sec =1,000,000,000,000 Picosecond (PS) 1 picosecond =1/1,000,000,000,000 sec (s)
1 minutes = 60 seconds
1 hours =60 minutes =3600 seconds
Second, System.currenttimemillis () calculation method
In the development process, many people are usually accustomed to using new date () to get the current time. What new Date () does is actually called System.currenttimemillis (). If it is just a need or a millisecond, then you can use System.currenttimemillis () instead of the new Date (), which is a bit more efficient. If you need to use the new Date () multiple times in the same method, the performance is typically 1.1-point consumption, where you can actually declare a reference.
Small example:
You can see that the output time is one hours after the current time.
System.currenttimemillis () +3600*1000) can be interpreted this way: System.currenttimemillis () is equivalent to milliseconds, but after 1000, it becomes in seconds. Then, 3,600 seconds = 1 hours, so the output is 1 hours after the current time.
We can control it this way: System.currenttimemillis () +time*1000), the incoming time is in seconds, when passed in 60, the output: one minute after the current time
You can see that the output time is one minute after the current time.
System.currenttimemillis () unit conversion of calculation mode and time