00:01
In this question, we have to write a code in java and in this implementation, we will have a add minute method.
00:17
So this method takes a time string and a number of minutes to add as argument.
00:22
So it first will pass the input time string into hours.
00:27
So it will either input time string that is there into the hours minutes and am pm components like this the am pm components that are there.
01:01
So it will then convert the time to a 24 hour con format that is there.
01:08
So it will also convert the time into 24 hour format.
01:20
So this will be done by adding the 12 hours.
01:23
So if the time is in pm, then after that it will add the specific number of minutes to the total minutes.
01:31
So this method will then calculate the new hours and minutes from the total minutes and everything and it will convert the result back to the 12 hour format that is there.
01:44
So it will then calculate to certain calculations that are necessary and then it will again convert the result to the 12 hour format.
01:58
This is given to us in the question.
02:07
So now we will see how to how we will proceed and write this code in java.
02:12
So for that we will be using a basic java compiler.
02:16
So here as you can see first, we will be defining the time adder class.
02:24
So this class will be containing a add minute method which will take two arguments.
02:32
So let us see how that is done.
02:35
So here as you can see, we have included an add minute method here.
02:42
So it has taken two arguments that is the string time and the number of minutes to add that is minutes to add.
02:50
So the time string here is passed to extract the hours, minutes and am pm components using the string manipulation as i told you.
02:59
So the substring method here is used to extract the relevant parts of the time string.
03:07
So the time is then converted to a 24 hour format by adding the 12 hours if the time is in the pm.
03:17
So let us see how that is converted.
03:21
So for that we will use this.
03:27
So this is if the format is in the 24 hour format.
03:32
So it will convert time to a 24 hour format for easier calculation.
03:37
Then we have to add the minutes...