Question: JAVA Define the class called Date which will be used to read, create, and manipulate dates. The class has 3 instance variables as shown below:

JAVA

Define the class called "Date" which will be used to read, create, and manipulate dates. The class has 3 instance variables as shown below:

private int day;

private int month;

private int year;

The class should have a constructor public Date(int day, int month, int year) to create a new Date type object given parameters for day, month and year. No error handling is needed here in this constructor

The class should also have a constructor method to create a new Date type object from an existing Date type object (i.e.copy constructor).

The class also needs an additional constructor which can create a Date type object from by taking into a string in the form of "DD/MM/YYYY". Where DD is for day, MM is month (a preceding 0 will be used for days and months less than 10, ex. Jan 1 is 01/01), and YYY is the year. The constructor may use any classes and/or methods you choose to accomplish this task, but I will point you towards the substring method in String, and the static method parseInt of the wrapper class Integer as a good method to look at.

The class should have an accessor method for each of the three instance variables

Define an equals method, boolean equals(Date date) , to compare the contents of two Date objects to see if they are equal

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!