0% found this document useful (0 votes)
4 views1 page

Java Date Class Implementation Guide

This document outlines requirements for developing a Java class to represent dates, including a constructor that accepts year, month, and day integers; a setToNextDay method that increments the date by one day; a toString method that returns the date as a string in yyyy/MM/dd format; and a compareTo method that compares the current date object to another date object parameter and returns -1 if earlier, 0 if equal, or 1 if later.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Java Date Class Implementation Guide

This document outlines requirements for developing a Java class to represent dates, including a constructor that accepts year, month, and day integers; a setToNextDay method that increments the date by one day; a toString method that returns the date as a string in yyyy/MM/dd format; and a compareTo method that compares the current date object to another date object parameter and returns -1 if earlier, 0 if equal, or 1 if later.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Problem Statement

Date Class
You are in charge of developing a java class that represents a date with year, month and day. You must
implement at least

a class with
at least the following methods:
Method name

Parameters and Return type

Description

constructor

Parameters:

Constructor method for passing down a


date

- An integer that represents the year of


the date
- An integer that represents the month of
the date
- An integer that represents the day of
the month
setToNextDay

Parameters:

The method must set the current date


object value to the next day

- No apply
Return Type:
- void
toString

Parameters:

Returns the String representation of a date


object in the format yyyy/MM/dd

- No apply
Return Type:
- [Link]
compareTo

Parameters:
- An object of date type
Return Type:
[Link]

Compare the current date object and the


one passed as parameter. If both objects
represent the same date the method must
return 0. If the current date object
represents a date previous to the date
object passed as parameter, the method
must return -1 otherwise the method must
return 1.

You might also like