Answers for "time java"

3

java time code

final long startTime = System.currentTimeMillis();
for (int i = 0; i < length; i++) {
  // Do something
}
final long endTime = System.currentTimeMillis();

System.out.println("Total execution time: " + (endTime - startTime));
Posted by: Guest on April-21-2020
12

java date time

import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;  
public class CurrentDateTimeExample1 {  
  public static void main(String[] args) {  
   DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
   LocalDateTime now = LocalDateTime.now();
   System.out.println(dtf.format(now));
  }  
}
Posted by: Guest on June-03-2020
0

java time

import java.time.LocalTime; // import the LocalTime class
...
// To display the current time (hour, minute, second, and nanoseconds)
LocalTime time = LocalTime.now();
System.out.println(time); // 11:04:57.416546
Posted by: Guest on June-22-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language