long startTime = System.currentTimeMillis(); // Code to be timed goes here long endTime = System.currentTimeMillis(); long timeTaken = endTime - startTime; System.out.println("Time taken (in ms): " + timeTaken);
long startMillis = System.currentTimeMillis(); // Do some work here long elapsedMillis = System.currentTimeMillis() - startMillis; System.out.println("Elapsed time (in ms): " + elapsedMillis);
UUID uuid = new UUID(System.currentTimeMillis(), 0); System.out.println("Generated UUID: " + uuid.toString());The System class is part of the core Java library (java.lang), which is available by default in any Java environment/runtime.