Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
36 views
asked by Expert (15k points) 15 23 32

1 Answer

0 votes
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");
  }

}
answered by Sr Member (4.8k points) 10 26 32

Related questions

0 votes
1 answer 17 views
17 views asked by felin Advisor (8.4k points) 10 15 18
0 votes
2 answers 28 views
28 views asked by john Guru (27.1k points) 35 53 115
0 votes
1 answer 20 views
20 views asked by felin Advisor (8.4k points) 10 15 18
0 votes
1 answer 82 views
0 votes
2 answers 30 views
30 views asked by john Guru (27.1k points) 35 53 115
...