2. Develop Date class in Java similar to the one available in java.util package. Use JavaDoc comments.
ALGORITHM:
STEP 1: Create a package which consists of constructors with the following arguments:
i) Default
ii)Taking 3 arguments year, day and month
iii)Taking 5 arguments year, day, month, hours and minutes
iv)Taking 6 arguments year, day, month, hour, minutes and seconds
STEP 2: Get the year, month, date, hours, minutes, seconds using the getYear(),
getMonth(), getDate(), getHours(), getMinutes(), getSeconds() methods.
STEP 3: Set all these details using set methods.
STEP 4: After()-the after() method returns true if the current date comes after the
specified date else it returns false
STEP 5: Before()-the before()method returns true if the current date comes before the
specified date else it returns false
STEP 6: Compare()-the compare() method compares the current date with the specified
date and returns 0 if it is equal,if after it returns 1 and if before it returns -1.
0 comments:
Post a Comment