013-003-005
LocalDate Class: Today's Date
Easy
Problem Description
LocalDate class: Today's Date
In this problem, you will create a program that retrieves the current date using LocalDate.now(), extracts the year, month, and day individually, and displays the result to standard output.
Learning Objective: Get current date with LocalDate.now()
Use the now() method of the java.time.LocalDate class to obtain today's date, then use getYear(), getMonthValue(), and getDayOfMonth() to extract and display each component separately.
Input
None
Output
Today: [yyyy-MM-dd]
Year: [year]
Month: [month]
Day: [day]
Test Cases
※ Output examples follow programming industry standards
Input:
Expected Output:
Today: \d{4}-\d{2}-\d{2}\nYear: \d{4}\nMonth: (?:[1-9]|1[0-2])\nDay: (?:[1-9]|[12]\d|3[01])Input:
Expected Output:
Today: \d{4}-\d{2}-\d{2}\nYear: \d{4}\nMonth: (?:[1-9]|1[0-2])\nDay: (?:[1-9]|[12]\d|3[01])Input:
Expected Output:
Today: \d{4}-\d{2}-\d{2}\nYear: \d{4}\nMonth: (?:[1-9]|1[0-2])\nDay: (?:[1-9]|[12]\d|3[01])Input:
Expected Output:
Today: \d{4}-\d{2}-\d{2}\nYear: \d{4}\nMonth: (?:[1-9]|1[0-2])\nDay: (?:[1-9]|[12]\d|3[01])❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 7 free executions remaining
