نمایش تاریخ و زمان فعلی(Display Current Date and Time)

برای نمایش تاریخ و زمان فعلی، کلاس java.time.LocalDateTime را وارد کنید و از now():




مثال


import java.time.LocalDateTime; // import the LocalDateTime class

public class MyClass {
  public static void main(String[] args) {
    LocalDateTime myObj = LocalDateTime.now();
    System.out.println(myObj);
  }
}

The output will be: