Member-only story
How will you get the current date and time using Java8 Date and Time API ?
Sep 29, 2023
Java 8 Date Time API to get current date and time.
package com.demo.main;
public class GetCurrentDateAndTime {
public static void main(String[] args) {
// LocalDate API to get the current Date
System.out.println("Current Date : "+java.time.LocalDate.now());
// LocalTime API to get the current Time
System.out.println("Current Time : "+java.time.LocalTime.now());
// LocalDateTime to get current Date and Time.
System.out.println("Current Date And Time : "+java.time.LocalDateTime.now());
}
}
Watch Video Here :