6. 1. 8. 以毫秒为单位返回计算机的时间 |
|
public static long currentTimeMillis()
|
|
- The value represents the number of milliseconds that has elapsed since January 1, 1970 UTC.
- To get the string representation of the current computer time, use this:
|
System.out.println(new java.util.Date());
|
|
currentTimeMillis is useful if you want to time an operation. |
public class MainClass {
public static void main(String[] a) {
long start = System.currentTimeMillis();
// block of code to time
long end = System.currentTimeMillis();
System.out.println("It took " + (end - start) + " milliseconds");
}
}
|
|