How will you get the current date and time using Java 8 Date and Time API?

This program uses the Java 8 Date and Time API to print the current local date, time, and date-time.

Code Example:

class Java8 {

    public static void main(String[] args) {

        System.out.println("Current Local Date: " + java.time.LocalDate.now());
        System.out.println("Current Local Time: " + java.time.LocalTime.now());
        System.out.println("Current Local Date and Time: " + java.time.LocalDateTime.now());
    }
}