Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Subtracting time in java.

Doing an assignment in college which requires me to read in a start time and end time and then substract in order to get the duration time. I'm only a beginner so any help would be great.
http://lmgtfy.com/?q=java+time+duration

Help? First lesson: Google knows more than the people you're asking for help.
This is really basic. Have a look at the code below. It gives you the duration in milliseconds:

Code
long start = System.currentTimeMillis();
//do your stuff
long end = System.currentTimeMillis();

long duration = end - start;
1)read both the start and end time
2) convert them to epoch format
3) subtract them
4) divide to get the duration
get your start time and subtract it from your endtime?
lmbo just ur turn clock backwards xd


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by LockheedJan 15, 2019 04:05 PM 2 134 Jan 15, 2019 04:05 PM
Last Post: Lockheed
[C] by kplishereJan 10, 2019 07:59 PM 1 203 Jan 10, 2019 07:59 PM
Last Post: Europa
[Java] by President HolyFeb 8, 2014 11:48 AM 3 193 Feb 8, 2014 11:48 AM
Last Post: Knautschtabak