013-003-010

Calculating Date Differences and Periods

Hard

Problem Description

Calculating Date Differences and Periods

In this problem, you will create a program that reads two dates from Scanner input, calculates the difference in days using ChronoUnit, and displays the results to standard output.

Learning Objective: Understand calculating between dates using ChronoUnit and Period

Overview

Calculate the difference between two dates in days and months, and output the comparison result.

Specifications

  1. Read two dates from Scanner (year, month, day as integers, 6 integers total)
  2. Print Date1: <date1> and Date2: <date2>
  3. Print Days between: <days> (absolute value)
  4. Print Date1 is before Date2: <true/false>

Input Example

2025
1
1
2025
3
15

Output Format

Date1: 2025-01-01
Date2: 2025-03-15
Days between: 73
Date1 is before Date2: true

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