This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi my Java Program needs to increment the time for every five minutes starting at 6 am to 10 pm. 06:00:00 to 06:05:00 is the first interval, 06:05:00 to 06:10:00, 06:10:00 to 06:15:00, 06:15:00 to 06:20:00, etc etc etc etc 09:55:00 to 10:00:00
That's a good start. It doesn't look like it works after 7:00 though because the hour isn't adjusted before you set it.
You really only need to do this once, so you could do it outside the loop.
This is the critical piece of code and you have it right. Without the calendar1.set() methods, calendar1 will retain its value. So at the beginning of each loop, it is the same as the ending value from the previous loop.
Stylistically, you might want to show where 192 came from.