Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do get particular date of total time

 
Baktha Elumalai
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is our java code



this is output



i am getting the total time for all date

i need only the particular date of total time

2010-05-11-->total time
2010-05-12->Total time
2010-05-13->total time

how do i change the given code to get the above output
please help me anybody having idea
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross-post 1: Sun Forum Thread
Cross-post 2: Java-Forums Thread
Others?

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

and in particular this one: BeForthrightWhenCrossPostingToOtherSites

Much luck!

Pete
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic