013-003-005
LocalDate Class: Today's Date
Easy
Problem Description
LocalDate class: Date Operations
In this problem, you will create a program that reads year, month, and day as input, creates a date object using LocalDate.of(), extracts each component, and displays the result to standard output.
Learning Objective: Create a date with LocalDate.of() and retrieve each field using getYear(), getMonthValue(), getDayOfMonth()
Read year, month, and day with java.util.Scanner, then create a date object using the of() method of the java.time.LocalDate class. Then use getYear(), getMonthValue(), and getDayOfMonth() to extract and display each component separately.
Input
year month day
(3 space-separated integers)
Output
Today: [yyyy-MM-dd]
Year: [year]
Month: [month]
Day: [day]
Example
Input:
2025 6 15
Output:
Today: 2025-06-15
Year: 2025
Month: 6
Day: 15
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up