Java program to create a LocalDate object from the object of Date class
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Create a LocalDate object from the object of the Date class and print the result.
Program/Source Code:
The source code to create a LocalDate object from the object of the Date class is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created a class Main that contains a static method main(). The main() method is the entry point for the program, here we created an object of the Date class. Then we created the object of LocalDate class using Date class object using toInstant(), atZone(), and toLocalDate() methods. After that, we printed the result.