013-003-011
Basic LocalDate Operations
Easy
Problem Description
Basic LocalDate Operations
In this problem: You will use java.time.LocalDate to create specific dates, add and subtract days, calculate the number of days between two dates, and display the results to standard output.
Learning Objective: Master the basic operations of the Java 8+ date API (LocalDate): creation, addition, subtraction, and day count calculation
Overview
LocalDate is a class introduced in Java 8 for handling dates. It contains no time information and manages only year, month, and day. It is immutable, so each operation produces a new object.
Specifications
- Create January 1, 2025 using
LocalDate.of(2025, 1, 1)and display it - Add 30 days to that date and display the result
- Subtract 10 days from that date and display the result
- Calculate the number of days between January 1, 2025 and December 31, 2025 and display it
Output Format
Date: 2025-01-01
Plus 30 days: 2025-01-31
Minus 10 days: 2024-12-22
Days between: 364
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