I need help creating this time class with these specific methods:

Time(hour, minute, PM)

Constructor that takes an hour and minute (integers) and a boolean value representing whether it is in the AM (false) or PM (true) time period.


This static method accepts a string such as “12:03 PM” and converts it into a Time object, which is returned. Your code must break apart the string in order to extract the individual integers and values such as 12, 3, and “PM” to interpret their meaning. If the string is in an invalid format, such as missing a colon or AM/PM or number, or if anything else goes wrong, throw an IllegalArgumentException


Returns true if and only if orefers to a Time object with exactly the same state as this one; otherwise returns false.

getHour(), getMinute()

Accessors for the time's hour and minute state.


Returns true if this time occurs between 12:00 PM (noon) and 11:59 PM inclusive.


Adjusts this time object forward in time by the given number of minutes (an integer). This might cause the object to wrap into the next hour or even wrap around to the next entire day. If the number of minutes is negative, throw an IllegalArgumentException. This method can be O(minutes) though it doesn't need to be.


Returns a string for this time in HH:MM AM/PM format. The hours and minutes are always shown as two-digit numbers, with a colon between and a space between the time and the AM/PM period. For example, “04:53 AM” or “12:07 PM”.

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now