Java 8 provides the following core Date and Time API Classess:-
1. LocalDate
2. LocalTime
3. LocalDateTime
The LocalDate, LocalTime and LocalDateTime denotes the current date and time in context of Observer.
Use now() method of LocalDate to get current date:-
LocalDate currentDate = LocalDate.now();
System.out.println("Current Date: " + currentDate);
Output:- Current Date: 2019-02-06
Use now() method of LocalDate to get current date:-
LocalTime currentTime = LocalTime.now();
System.out.println("Current Time: " + currentTime);
Output:- Current Time: 23:17:51.817