How to Display Current Date and Time in Java


In this example we will show the method to display current date and time in Java.

Source Code

package com.beginner.examples;

import java.time.LocalDateTime;

public class NowDate {  
  public static void main(String[] args) {
    LocalDateTime now = LocalDateTime.now(); // current date
    System.out.println(now);
  }
}

Output:

2020-05-13T08:07:35.905

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments