This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Loop and add the times while the date is the same?
Some other suggestions:
Use Meaningful Variable Names
Meaningful variable names help people reading your code to discover its intent. Names like "a", "b", "b1", "b2", etc. are almost never a good idea--particularly when a method is this long.
Methods Should Do Only One Thing
And do it well, and do it completely. Similar to how we say classes should have a single responsibility, so to should method. This makes them easier to understand, easier to test, easier to modify, etc. Methods this long should be refactored mercilessly.
Show Only Relevant Code
Particularly when asking for help, it's useful to show only code directly relevant to your question. Code that is commented out, code that has no useful effect (or side effect) should be eliminated for clarity.
Pay Attention to Code Structure and Formatting
Code structure and indention are another way of communicating intent. When there are multiple indent sizes/conventions it's distracting. IDEs have source formatting capabilities--use them.
Isolating What You Care About
Even with only simple formatting enforcement and the removal of useless code things are already easier to cope with, and the bulk of what you're *really* asking about is reduced to this:Note, by the way, that your original code did not handle the case where diffSeconds == 80--that may have been your intent, in which case my code slightly changes the functionality.
I still find the code difficult to follow, however.
Baktha, I hope that your question gets answered, but I think that most here would appreciate it, if when you cross-post a question you provide links to the other cross-posts. Nobody likes duplicating work that's already been done. Thanks for your cooperation. For more details, please look at the forum FAQ's: HowToAskQuestionsOnJavaRanch