Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how do get particular date of total time

Ranch Hand
Posts: 44
  • 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
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.
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

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!

The human mind is a dangerous plaything. This tiny ad is pretty safe:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic