Question: You are tasked with creating a Java program that converts dates from the numerical month / day / year format to the standard month day,

You are tasked with creating a Java program that converts dates from the numerical month/day/year format to the standard "month day, year" format. For instance, the date 12/25/2021 should be converted to December 25,2021. Your program should also handle various exceptions that may occur due to invalid inputs.
Requirements:
Your program should continuously prompt the user to enter a date in the MM/DD/YYYY format until a valid date is entered.
Validate the user input to ensure that:
The month is between 1 and 12.
The day is within the appropriate range for the given month and year (e.g.,31 days for January, March, May, July, August, October, and December; 30 days for April, June, September, and November; and 28 or 29 days for February depending on leap years).
The year is between 1000 and 3000.
If the user enters an invalid date, display an appropriate error message and ask them to re-enter the date.
Use exception handling to catch and handle the following exceptions:
NumberFormatException: Occurs when the input cannot be parsed as an integer.
ArrayIndexOutOfBoundsException: Occurs when the input does not contain enough parts (month, day, year).
MonthException: Custom exception class for invalid month inputs.
DayException: Custom exception class for invalid day inputs.
YearException: Custom exception class for invalid year inputs.
Use the switch statement to convert the numeric month to its corresponding name (e.g.,1 to January, 2 to February, etc.).
Display the formatted date in the "month day, year" format when a valid date is entered.
Hints:
Use the Scanner class for user input.
Utilize a try-catch block for exception handling.
Implement a loop to continuously ask for the date until a valid date is entered.
Use the String.split() or StringTokenizer() method to separate the input into month, day, and year parts.
Sample Output:
Enter date in MM/DD/YYYY format: 13/25/2021
Invalid month. Please enter a number between 1 and 12.
Enter date in MM/DD/YYYY format: 02/29/2021
Invalid day. Please enter a number between 1 and 28.
Enter date in MM/DD/YYYY format: 02/29/2020
Formatted date: February 29,2020

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!