24

I came across this question https://stackoverflow.com/questions/42736535/adding-specific-time-to-date-in-java

I have two date variables . I want to get the time from one date and assign thattime to another date.How can do it in java ?

firstdate = Mon Mar 13 00:00:00 IST 2017 second date = Thu Jan 01 12:00:00 IST 1970

I want to get hours from second date and add that hours to first date

This question Java string to date conversion and many others answer the first part of the problem.

This question Sum two dates in Java and many others answer the second part of the problem.

They are not difficult to search

java string data

java adding dates

  • Can these be closed as dupes? or
  • Can we have some close reason that covers questions like these? or
  • Should these questions be welcomed on the site?
11
  • 10
    Close as too broad.... the question quality is so bad.
    – Braiam
    Commented Mar 11, 2017 at 15:11
  • @Braiam have a look at the revision history, it was pinged into socvr by the low Q Q bot, that's how it caught my attention
    – user3956566
    Commented Mar 11, 2017 at 15:12
  • 1
    In the case of Java date and time questions (like this) there is an additional issue: the old answers use the old (and troublesome, as Basil Bourque would have added) classes Date, Calendar and GregorianCalendar. You may add a new answer using Java 8 date and time classes, but it would end at the bottom and not get noticed. An answer to the new question would.
    – Anonymous
    Commented Mar 12, 2017 at 7:41
  • 6
    @OleV.V. this answer I posted stackoverflow.com/questions/5721904/… was late to the post and has 10 upvotes. People who are trying to find something will trawl through answers (except for people who are lazy and expect others to do the hard work). I'm a believer it's worth adding new answers to old questions.
    – user3956566
    Commented Mar 12, 2017 at 8:22
  • Thanks, @YvetteColomb, for the encouragement. I have tried too, not with much success until now. This was just a week ago: stackoverflow.com/a/42596283/5772882, maybe I should give it a couple of years. Will continue.
    – Anonymous
    Commented Mar 12, 2017 at 9:32
  • @OleV.V. yes it takes time
    – user3956566
    Commented Mar 12, 2017 at 9:36
  • This answer to the question you linked to is 8 months old now and still at the bottom of 9 answers. I just gave it its first upvote. @YvetteColomb
    – Anonymous
    Commented Mar 12, 2017 at 9:39
  • 4
    I think your analysis of that question was all wrong. First, nobody said that the two dates are given as strings. The question simply said they were in variables. The values given could simply have been the values when those variables are printed. Second, the question was not about adding two dates (which is actually a nonsensical operation). It was about composing the date part from date A with the time part from date B. Most of the questions you have shown do not answer that. Conclusion: the question is bad. Should have been closed, but not as a duplicate of any of your suggested dupes. Commented Mar 12, 2017 at 17:02
  • 1
    related: More than one question per post
    – gnat
    Commented Mar 13, 2017 at 8:31
  • 4
    By your questions combined, I am Captain Dupehammer!
    – Machavity Mod
    Commented Mar 13, 2017 at 12:48
  • @RealSkeptic maybe not the best example then, but I think most people get my point ;)
    – user3956566
    Commented Mar 13, 2017 at 13:40

2 Answers 2

49

One option, especially if you're a gold badger, is to close as a duplicate and then edit the duplicate link banner to include the second link. Or, if you're friendly with someone who has that ability, ping them to do the edit. (But please don't badger a badger you don't know.)

This is explicitly mentioned in that feature announcement post as one of the reasons it was implemented:

... useful in cases where more than one duplicate was appropriate ...

12
  • Sure thing, @Yvette. Not sure whether this is the best option, but it's not a bad one.
    – jscs
    Commented Mar 11, 2017 at 15:14
  • Yeh, I'd like to accept this answer, as I think it's a perfect option, but I think it's preferable to allow the community to weigh in first.
    – user3956566
    Commented Mar 11, 2017 at 15:16
  • Yes, I'd like to hear other ideas as well.
    – jscs
    Commented Mar 11, 2017 at 15:17
  • 3
    While I don't think it is bad idea I dislike "find gold badger" part. If you can't do it yourself then just close for lack of MCVE or too broad. Or just regular duplicate of main problem. I don't feel that "hey gold badger, someone asked too broad question and we need to close with 10 duplicates - go and do that" would be pleasnt exercise for gold holder and definitely will send wrong message that asking questions without any efforts to narrow it down is welcome.. Commented Mar 12, 2017 at 7:53
  • 27
    Gold badger
    – user4639281
    Commented Mar 12, 2017 at 17:34
  • 15
    MUSHROOM! MUSHROOM! Commented Mar 12, 2017 at 18:37
  • 1
    @AlexeiLevenkov: Fair point; I've edited to address your concern.
    – jscs
    Commented Mar 12, 2017 at 21:15
  • 3
    If you cannot close as a duplicate and edit, just post the links as comments. Should anyone come across them, they may edit them into the message if they agree - no extra pinging necessary. If you think it's important, mention it in the SOCV chat
    – Bergi
    Commented Mar 13, 2017 at 13:30
  • 1
    @Bergi Was just going to ask if SOCV chat would be an appropriate place to ask. ("Order of the Golden Badger, I have a mission for you...") I don't personally know anyone with a higher SO score than myself (and mine is not terribly high), so I was actually a bit taken aback by the suggestion of pinging someone personally about this--you make the SO gold-badge community sound like some sort of cabal where everyone knows each other! (I exaggerate, of course.) Commented Mar 13, 2017 at 15:34
  • I'm curious to know why that same (edit) option is not available for meta questions. One such as this one where another possible duplicate would have been this one. Or, is there a meta post about this also? Commented Apr 5, 2017 at 17:21
  • @Fred-ii- You (and I) don't see the option because you don't have any of the appropriate tag badges.
    – jscs
    Commented Apr 5, 2017 at 17:24
  • @JoshCaswell Oh, I see. Thank you Josh. Edit: Sorry for the bother. Commented Apr 5, 2017 at 17:25
13

That OP couldn't figure out that he had two problems instead of one, is not our issue. One of the quality all programmers should have (in fact, you can't call yourself a programmer without it) is the ability of breaking a task into its individual components and solve them one by one. No language has a function called themiraclehappens() that does all the things (except jQuery).

All questions should focus on 1 issue, that makes them searchable, otherwise we would have several questions which are partial duplicate of every question of the site, because the user couldn't figure out that he needs more than one step to solve his issue.

9
  • 1
    Yes you make a good point thanks.
    – user3956566
    Commented Mar 11, 2017 at 15:19
  • 2
    Agreed with this, but can you be more explicit about the course of action you're recommending? I guess you're advocating VTCing as "Too Broad"?
    – jscs
    Commented Mar 11, 2017 at 15:40
  • @JoshCaswell or unclear, or pob. If you are asking a question which has several disparate answer depending on the focus, it could be closed on any grounds. I don't advocate on a specific reason, since I want the reader to evaluate for itself which reason is more appropriated.
    – Braiam
    Commented Mar 11, 2017 at 15:55
  • 11
    -1 not enough jQuery in this answer
    – Nic
    Commented Mar 12, 2017 at 22:07
  • 1
    You could argue as well that most questions are answered in the docs, which a programmer should be able to read. My point is: it's difficult to decide for someone else, which problem he should be able to solve for himself.
    – rboehme
    Commented Mar 13, 2017 at 8:56
  • 2
    @rboehme that's lack of research, not lack of reasoning skill.
    – Braiam
    Commented Mar 13, 2017 at 13:02
  • And the fact that you misread the question as two problems is only partially the OP's issue. There are countless ways to phrase a question, but just because someone interprets it incorrectly doesn't mean the OP lacks reasoning skill. That's why we leave comments below the question. Granted, there's a better way to ask most questions, but not everyone is as gifted as you. We know what qualities programmers should have, so let's ridicule them and shoot out opinions like "question quality is so bad" and "not our issue" while not using an ounce of brainpower to examine what is being asked. Commented Mar 14, 2017 at 21:51
  • 1
    @GlennFromIowa a post from which you can derive multiple questions is no good: answerers can answer any/every question and go on tangential topics, visitors could land on the question even if none of the answers addresses their issue, tons of time loss trying to evaluate answers usefulness since we don't know which aspect is being answered, etc. It's on multiple aspects a problematic question. One would expect someone to ask focused questions to people willing to answer them, is a form of respect. Lacking the ability to be able to craft questions that way, indicate that or laziness.
    – Braiam
    Commented Mar 14, 2017 at 21:59
  • On the surface, I get what you're saying, and there is an art to asking questions on SO. But on this particular question, it seems so straightforward - they said "I have two date variables." Perhaps it could be split into 2 questions on extracting the time and adding that to the other variable, but really, you couldn't figure out that the basic question was how to reference the time part of the date variable? And then you implied they couldn't possibly be a competent programmer. Maybe I need read the bible of SO again, but I don't get the "multiple aspects" of problems with this question. Commented Mar 14, 2017 at 22:22

You must log in to answer this question.