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
- 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?
Date
,Calendar
andGregorianCalendar
. 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.